diff --git a/init.lua b/init.lua index 235a3fc..baa64bf 100644 --- a/init.lua +++ b/init.lua @@ -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 \ No newline at end of file