forked from VoxeLibre/VoxeLibre
Renamed some functions and variables
* changed names referring to player where it does support mobs * also added an is_player() check in one function
This commit is contained in:
parent
03c73b7820
commit
0e33947258
|
@ -104,7 +104,7 @@ function mcl_raids.promote_to_raidcaptain(c) -- object
|
|||
mcl_raids.drop_obanner(pos)
|
||||
if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then
|
||||
awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile")
|
||||
local lv = mcl_potions.player_get_effect(cmi_cause.puncher, "bad_omen")
|
||||
local lv = mcl_potions.get_effect(cmi_cause.puncher, "bad_omen")
|
||||
if not lv then lv = 0
|
||||
else lv = lv.factor end
|
||||
lv = math.max(5,lv + 1)
|
||||
|
@ -296,7 +296,7 @@ mcl_events.register_event("raid",{
|
|||
--minetest.log("Cond start raid")
|
||||
local r = {}
|
||||
for _,p in pairs(minetest.get_connected_players()) do
|
||||
if mcl_potions.player_has_effect(p,"bad_omen") then
|
||||
if mcl_potions.has_effect(p,"bad_omen") then
|
||||
local raid_pos = mcl_raids.find_village(p:get_pos())
|
||||
if raid_pos then
|
||||
--minetest.log("We have a raid position. Start raid")
|
||||
|
@ -310,7 +310,7 @@ mcl_events.register_event("raid",{
|
|||
self.mobs = {}
|
||||
self.health_max = 1
|
||||
self.health = 0
|
||||
local lv = mcl_potions.player_get_effect(minetest.get_player_by_name(self.player), "bad_omen")
|
||||
local lv = mcl_potions.get_effect(minetest.get_player_by_name(self.player), "bad_omen")
|
||||
if lv and lv.factor and lv.factor > 1 then self.max_stage = 6 end
|
||||
end,
|
||||
cond_progress = function(self)
|
||||
|
@ -331,7 +331,7 @@ mcl_events.register_event("raid",{
|
|||
end,
|
||||
on_complete = function(self)
|
||||
awards.unlock(self.player,"mcl:hero_of_the_village")
|
||||
mcl_potions.player_clear_effect(minetest.get_player_by_name(self.player),"bad_omen")
|
||||
mcl_potions.clear_effect(minetest.get_player_by_name(self.player),"bad_omen")
|
||||
make_firework(self.pos,os.time())
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -380,7 +380,7 @@ minetest.register_globalstep(function(dtime)
|
|||
etime = 0
|
||||
for _,pl in pairs(minetest.get_connected_players()) do
|
||||
local armor_feet = pl:get_inventory():get_stack("armor", 5)
|
||||
if pl and pl:get_player_control().sneak or (minetest.global_exists("mcl_enchanting") and mcl_enchanting.has_enchantment(armor_feet, "frost_walker")) or (minetest.global_exists("mcl_potions") and mcl_potions.player_has_effect(pl, "fire_proof")) then
|
||||
if pl and pl:get_player_control().sneak or (minetest.global_exists("mcl_enchanting") and mcl_enchanting.has_enchantment(armor_feet, "frost_walker")) or (minetest.global_exists("mcl_potions") and mcl_potions.has_effect(pl, "fire_proof")) then
|
||||
return
|
||||
end
|
||||
burn_in_campfire(pl)
|
||||
|
|
|
@ -135,7 +135,7 @@ minetest.register_node("mcl_nether:magma", {
|
|||
-- From walkover mod
|
||||
on_walk_over = function(loc, nodeiamon, player)
|
||||
local armor_feet = player:get_inventory():get_stack("armor", 5)
|
||||
if player and player:get_player_control().sneak or (minetest.global_exists("mcl_enchanting") and mcl_enchanting.has_enchantment(armor_feet, "frost_walker")) or (minetest.global_exists("mcl_potions") and mcl_potions.player_has_effect(player, "fire_proof")) then
|
||||
if player and player:get_player_control().sneak or (minetest.global_exists("mcl_enchanting") and mcl_enchanting.has_enchantment(armor_feet, "frost_walker")) or (minetest.global_exists("mcl_potions") and mcl_potions.has_effect(player, "fire_proof")) then
|
||||
return
|
||||
end
|
||||
-- Hurt players standing on top of this block
|
||||
|
|
|
@ -1145,32 +1145,33 @@ function mcl_potions._load_player_effects(player)
|
|||
end
|
||||
end
|
||||
|
||||
-- Returns true if player has given effect
|
||||
function mcl_potions.player_has_effect(player, effect_name)
|
||||
-- Returns true if object has given effect
|
||||
function mcl_potions.has_effect(object, effect_name)
|
||||
if not EF[effect_name] then
|
||||
return false
|
||||
end
|
||||
return EF[effect_name][player] ~= nil
|
||||
return EF[effect_name][object] ~= nil
|
||||
end
|
||||
|
||||
function mcl_potions.player_get_effect(player, effect_name)
|
||||
if not EF[effect_name] or not EF[effect_name][player] then
|
||||
function mcl_potions.get_effect(object, effect_name)
|
||||
if not EF[effect_name] or not EF[effect_name][object] then
|
||||
return false
|
||||
end
|
||||
return EF[effect_name][player]
|
||||
return EF[effect_name][object]
|
||||
end
|
||||
|
||||
function mcl_potions.player_get_effect_level(player, effect_name)
|
||||
function mcl_potions.get_effect_level(object, effect_name)
|
||||
if not EF[effect_name] then return end
|
||||
local effect = EF[effect_name][player]
|
||||
local effect = EF[effect_name][object]
|
||||
if not effect then return 0 end
|
||||
if not registered_effects[effect_name].uses_factor then return 1 end
|
||||
return registered_effects[effect_name].factor_to_level(effect.factor)
|
||||
end
|
||||
|
||||
function mcl_potions.player_clear_effect(player,effect)
|
||||
EF[effect][player] = nil
|
||||
potions_set_hud(player)
|
||||
function mcl_potions.clear_effect(object, effect)
|
||||
EF[effect][object] = nil
|
||||
if not object:is_player() then return end
|
||||
potions_set_hud(object)
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer( function(player)
|
||||
|
|
|
@ -186,7 +186,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso
|
|||
do_poison = true
|
||||
end
|
||||
if do_poison then
|
||||
local level = mcl_potions.player_get_effect_level(user, "food_poisoning")
|
||||
local level = mcl_potions.get_effect_level(user, "food_poisoning")
|
||||
mcl_potions.give_effect_by_level("food_poisoning", user, level+exhaust, poisontime)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue