Fix pl_hook player loop and timing bug
This commit is contained in:
parent
680943fb10
commit
6d236fe10d
@ -22,22 +22,17 @@ end
|
|||||||
adventuretest.pl_hooks = {}
|
adventuretest.pl_hooks = {}
|
||||||
function adventuretest.player_loop(dtime)
|
function adventuretest.player_loop(dtime)
|
||||||
local p = minetest.get_connected_players()
|
local p = minetest.get_connected_players()
|
||||||
local reset_hooks = { }
|
local reset_hooks = {}
|
||||||
for _, player in pairs(p) do
|
|
||||||
local name = player:get_player_name()
|
|
||||||
for k,hook in pairs(adventuretest.pl_hooks) do
|
for k,hook in pairs(adventuretest.pl_hooks) do
|
||||||
adventuretest.pl_hooks[k].timer = adventuretest.pl_hooks[k].timer + dtime
|
adventuretest.pl_hooks[k].timer = adventuretest.pl_hooks[k].timer + dtime
|
||||||
if adventuretest.pl_hooks[k].timer >= adventuretest.pl_hooks[k].timeout then
|
if adventuretest.pl_hooks[k].timer >= adventuretest.pl_hooks[k].timeout then
|
||||||
reset_hooks[#reset_hooks+1] = k
|
for _, player in pairs(p) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
adventuretest.pl_hooks[k].timer = 0
|
||||||
adventuretest.pl_hooks[k].func(player,name,dtime)
|
adventuretest.pl_hooks[k].func(player,name,dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #reset_hooks > 0 then
|
|
||||||
for _,hid in pairs(reset_hooks) do
|
|
||||||
adventuretest.pl_hooks[hid].timer = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function adventuretest.register_pl_hook(f,t)
|
function adventuretest.register_pl_hook(f,t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user