set up player key store on join

This commit is contained in:
wsor4035 2023-12-03 15:03:02 -05:00
parent af05a85d89
commit 360c8ce98b

@ -7,6 +7,9 @@ controls = {
registered_on_press = {},
registered_on_hold = {},
registered_on_release = {},
--store player control data
players = {},
}
--api functions
@ -22,6 +25,18 @@ function controls.register_on_release(callback)
table.insert(controls.registered_on_release, callback)
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
dofile(controls.modpath .. "/test.lua")
end