mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-18 00:51:06 +01:00
Fix controls mod crashing in 5.3.0-dev
This commit is contained in:
parent
f519736e12
commit
4524aee758
1 changed files with 20 additions and 11 deletions
|
@ -16,19 +16,24 @@ function controls.register_on_hold(func)
|
||||||
controls.registered_on_hold[#controls.registered_on_hold+1]=func
|
controls.registered_on_hold[#controls.registered_on_hold+1]=func
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local known_controls = {
|
||||||
|
jump=true,
|
||||||
|
right=true,
|
||||||
|
left=true,
|
||||||
|
LMB=true,
|
||||||
|
RMB=true,
|
||||||
|
sneak=true,
|
||||||
|
aux1=true,
|
||||||
|
down=true,
|
||||||
|
up=true,
|
||||||
|
}
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
controls.players[name] = {
|
controls.players[name] = {}
|
||||||
jump={false},
|
for cname,_ in pairs(known_controls) do
|
||||||
right={false},
|
controls.players[name][cname] = { false }
|
||||||
left={false},
|
end
|
||||||
LMB={false},
|
|
||||||
RMB={false},
|
|
||||||
sneak={false},
|
|
||||||
aux1={false},
|
|
||||||
down={false},
|
|
||||||
up={false}
|
|
||||||
}
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
@ -40,7 +45,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local player_controls = player:get_player_control()
|
local player_controls = player:get_player_control()
|
||||||
|
if controls.players[player_name] then
|
||||||
for cname, cbool in pairs(player_controls) do
|
for cname, cbool in pairs(player_controls) do
|
||||||
|
if known_controls[cname] == true then
|
||||||
--Press a key
|
--Press a key
|
||||||
if cbool==true and controls.players[player_name][cname][1]==false then
|
if cbool==true and controls.players[player_name][cname][1]==false then
|
||||||
for _, func in pairs(controls.registered_on_press) do
|
for _, func in pairs(controls.registered_on_press) do
|
||||||
|
@ -60,4 +67,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue