Update init.lua

This commit is contained in:
Arcelmi 2017-09-14 15:22:07 +02:00 committed by GitHub
parent f6d0be86ae
commit cfac8183bd

@ -43,20 +43,20 @@ minetest.register_globalstep(function(dtime)
for cname, cbool in pairs(player_controls) do for cname, cbool in pairs(player_controls) do
--Press a key --Press a key
if cbool==true and controls.players[player_name][cname][1]==false then if cbool==true and controls.players[player_name][cname][1]==false then
controls.players[player_name][cname] = {true, os.clock()}
for _, func in pairs(controls.registered_on_press) do for _, func in pairs(controls.registered_on_press) do
func(player, cname) func(player, cname)
end end
controls.players[player_name][cname] = {true, os.clock()}
elseif cbool==true and controls.players[player_name][cname][1]==true then elseif cbool==true and controls.players[player_name][cname][1]==true then
for _, func in pairs(controls.registered_on_hold) do for _, func in pairs(controls.registered_on_hold) do
func(player, cname, os.clock()-controls.players[player_name][cname][2]) func(player, cname, os.clock()-controls.players[player_name][cname][2])
end end
--Release a key --Release a key
elseif cbool==false and controls.players[player_name][cname][1]==true then elseif cbool==false and controls.players[player_name][cname][1]==true then
controls.players[player_name][cname] = {false}
for _, func in pairs(controls.registered_on_release) do for _, func in pairs(controls.registered_on_release) do
func(player, cname) func(player, cname, os.clock()-controls.players[player_name][cname][2])
end end
controls.players[player_name][cname] = {false}
end end
end end
end end