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