mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-30 18:33:43 +01:00
more sugar
This commit is contained in:
parent
b7f1e92ed5
commit
67c55e6488
6
init.lua
6
init.lua
@ -57,16 +57,16 @@ minetest.register_globalstep(function(dtime)
|
|||||||
|
|
||||||
--consider using minetest.get_us_time() instead of os.clock()? would need to convert to seconds however
|
--consider using minetest.get_us_time() instead of os.clock()? would need to convert to seconds however
|
||||||
for key, key_status in pairs(pcontrols) do
|
for key, key_status in pairs(pcontrols) do
|
||||||
if key_status and controls.players[pname][key][1]==false then
|
if key_status and not controls.players[pname][key][1] then
|
||||||
for _, callback in pairs(controls.registered_on_press) do
|
for _, callback in pairs(controls.registered_on_press) do
|
||||||
callback(player, key)
|
callback(player, key)
|
||||||
end
|
end
|
||||||
controls.players[pname][key] = {true, os.clock()}
|
controls.players[pname][key] = {true, os.clock()}
|
||||||
elseif key_status and controls.players[pname][key][1]==true then
|
elseif key_status and controls.players[pname][key][1] then
|
||||||
for _, callback in pairs(controls.registered_on_hold) do
|
for _, callback in pairs(controls.registered_on_hold) do
|
||||||
callback(player, key, os.clock() - controls.players[pname][key][2])
|
callback(player, key, os.clock() - controls.players[pname][key][2])
|
||||||
end
|
end
|
||||||
elseif not key_status and controls.players[pname][key][1]==true then
|
elseif not key_status and controls.players[pname][key][1] then
|
||||||
for _, callback in pairs(controls.registered_on_release) do
|
for _, callback in pairs(controls.registered_on_release) do
|
||||||
callback(player, key, os.clock() - controls.players[pname][key][2])
|
callback(player, key, os.clock() - controls.players[pname][key][2])
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user