mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-24 07:33: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
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user