mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-08 08:03:47 +01:00
set up player key store on join
This commit is contained in:
parent
af05a85d89
commit
360c8ce98b
15
init.lua
15
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
|
Loading…
Reference in New Issue
Block a user