From 360c8ce98b4c54e7f9be7c4d8ba4d30c7acdd355 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 3 Dec 2023 15:03:02 -0500 Subject: [PATCH] set up player key store on join --- init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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