mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-28 09:33:44 +01:00
set up player key store on join
This commit is contained in:
parent
ba2402c056
commit
1839dc8954
15
init.lua
15
init.lua
@ -7,6 +7,9 @@ controls = {
|
|||||||
registered_on_press = {},
|
registered_on_press = {},
|
||||||
registered_on_hold = {},
|
registered_on_hold = {},
|
||||||
registered_on_release = {},
|
registered_on_release = {},
|
||||||
|
|
||||||
|
--store player control data
|
||||||
|
players = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--api functions
|
--api functions
|
||||||
@ -22,6 +25,18 @@ function controls.register_on_release(callback)
|
|||||||
table.insert(controls.registered_on_release, callback)
|
table.insert(controls.registered_on_release, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player, _)
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
local controls_names = player:get_player_control()
|
||||||
|
|
||||||
|
--note: could hardcode this, but this is more future proof in case minetest adds more controls
|
||||||
|
controls.players[pname] = {}
|
||||||
|
for key, _ in pairs(controls_names) do
|
||||||
|
controls.players[pname][key] = {false} --in theory its false when they join, but hard coding just in case
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
--tests
|
||||||
if(controls.testsmode) then
|
if(controls.testsmode) then
|
||||||
dofile(controls.modpath .. "/test.lua")
|
dofile(controls.modpath .. "/test.lua")
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user