mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-23 23:23:43 +01:00
Update init.lua
This commit is contained in:
parent
f6d0be86ae
commit
cfac8183bd
6
init.lua
6
init.lua
@ -43,20 +43,20 @@ minetest.register_globalstep(function(dtime)
|
||||
for cname, cbool in pairs(player_controls) do
|
||||
--Press a key
|
||||
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
|
||||
func(player, cname)
|
||||
end
|
||||
controls.players[player_name][cname] = {true, os.clock()}
|
||||
elseif cbool==true and controls.players[player_name][cname][1]==true then
|
||||
for _, func in pairs(controls.registered_on_hold) do
|
||||
func(player, cname, os.clock()-controls.players[player_name][cname][2])
|
||||
end
|
||||
--Release a key
|
||||
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
|
||||
func(player, cname)
|
||||
func(player, cname, os.clock()-controls.players[player_name][cname][2])
|
||||
end
|
||||
controls.players[player_name][cname] = {false}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user