tabs not spaces

This commit is contained in:
OgelGames 2023-12-04 19:23:45 +11:00
parent 1d3d25dc66
commit 776e527663
2 changed files with 29 additions and 29 deletions

@ -1,21 +1,21 @@
controls.register_on_press(function(player, key)
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " pressed " .. key)
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " pressed " .. key)
end)
controls.register_on_hold(function(player, key, length)
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " held " .. key .. " for " .. length .. " seconds")
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " held " .. key .. " for " .. length .. " seconds")
end)
controls.register_on_release(function(player, key, length)
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " released " .. key .. " after " .. length .. " seconds")
local name = player:get_player_name()
minetest.chat_send_player(name, name .. " released " .. key .. " after " .. length .. " seconds")
end)
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
minetest.chat_send_player(name, #controls.registered_on_press .. " registered_on_press callbacks")
minetest.chat_send_player(name, #controls.registered_on_hold .. " registered_on_hold callbacks")
minetest.chat_send_player(name, #controls.registered_on_release .. " registered_on_release callbacks")
local name = player:get_player_name()
minetest.chat_send_player(name, #controls.registered_on_press .. " registered_on_press callbacks")
minetest.chat_send_player(name, #controls.registered_on_hold .. " registered_on_hold callbacks")
minetest.chat_send_player(name, #controls.registered_on_release .. " registered_on_release callbacks")
end)

@ -1,33 +1,33 @@
controls = {
registered_on_press = {},
registered_on_hold = {},
registered_on_release = {},
players = {},
registered_on_press = {},
registered_on_hold = {},
registered_on_release = {},
players = {},
}
function controls.register_on_press(callback)
table.insert(controls.registered_on_press, callback)
table.insert(controls.registered_on_press, callback)
end
function controls.register_on_hold(callback)
table.insert(controls.registered_on_hold, callback)
table.insert(controls.registered_on_hold, callback)
end
function controls.register_on_release(callback)
table.insert(controls.registered_on_release, callback)
table.insert(controls.registered_on_release, callback)
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
controls.players[name] = {}
for key in pairs(player:get_player_control()) do
controls.players[name][key] = {false}
end
local name = player:get_player_name()
controls.players[name] = {}
for key in pairs(player:get_player_control()) do
controls.players[name][key] = {false}
end
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
controls.players[name] = nil
local name = player:get_player_name()
controls.players[name] = nil
end)
local function update_player_controls(player, player_controls)
@ -52,14 +52,14 @@ local function update_player_controls(player, player_controls)
end
minetest.register_globalstep(function()
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if controls.players[name] then
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if controls.players[name] then
update_player_controls(player, controls.players[name])
end
end
end
end)
if minetest.settings:get_bool("controls_enable_debug", false) then
dofile(minetest.get_modpath("controls") .. "/debug.lua")
dofile(minetest.get_modpath("controls") .. "/debug.lua")
end