forked from VoxeLibre/VoxeLibre
make abm work with timestamp
This commit is contained in:
parent
121bbb6910
commit
10a607be7e
|
@ -83,6 +83,8 @@ minetest.register_node("mcl_beacons:beacon", {
|
|||
inv:set_size("input", 1)
|
||||
local form = formspec_string
|
||||
meta:set_string("formspec", form)
|
||||
|
||||
meta:set_int("last-effect-cycle", os.time()-10)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght then
|
||||
|
@ -188,28 +190,28 @@ local function effect_player(effect,pos,power_level, effect_level)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function abm_function(pos)
|
||||
local power_level = beacon_blockcheck(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local effect_string = meta:get_string("effect")
|
||||
if meta:get_int("effect_level") == 2 and power_level < 4 then
|
||||
return
|
||||
else
|
||||
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"))
|
||||
if(meta:get_int("last-effect-cycle")+10 < os.time()) then
|
||||
meta:set_int("last-effect-cycle", os.time())
|
||||
local power_level = beacon_blockcheck(pos)
|
||||
local effect_string = meta:get_string("effect")
|
||||
if meta:get_int("effect_level") == 2 and power_level < 4 then
|
||||
return
|
||||
else
|
||||
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
minetest.register_abm{
|
||||
label = "beacon check & apply effect(s)",
|
||||
nodenames = {"mcl_beacons:beacon"},
|
||||
interval = 5,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = abm_function,
|
||||
}
|
Loading…
Reference in New Issue