mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-11-06 09:09:26 +02:00
added debug support
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
_DEBUG = false
|
||||
|
||||
global.scenario = {}
|
||||
global.spys = {"valansch", "air20"}
|
||||
global.scenario.variables = {}
|
||||
|
||||
@@ -448,6 +448,7 @@ local function pool()
|
||||
end
|
||||
end
|
||||
|
||||
if not _DEBUG then
|
||||
local old_add_command = commands.add_command
|
||||
commands.add_command = function(name, desc, func)
|
||||
old_add_command(name, desc, function(cmd)
|
||||
@@ -457,6 +458,7 @@ commands.add_command = function(name, desc, func)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command("kill", "Will kill you.", kill)
|
||||
commands.add_command("tpplayer", "<player> - Teleports you to the player. (Admins and moderators)", teleport_player)
|
||||
@@ -468,7 +470,7 @@ commands.add_command("regular", '<promote, demote>, <player> Change regular stat
|
||||
commands.add_command("mods", 'Prints a list of game mods.', print_mods)
|
||||
commands.add_command("mod", '<promote, demote>, <player> Changes moderator status of a player. (Admins only)', mod)
|
||||
commands.add_command("afk", 'Shows how long players have been afk.', afk)
|
||||
commands.add_command("tag", '<player> <tag> Sets a players tag. (Admins only)', tag)
|
||||
--commands.add_command("tag", '<player> <tag> Sets a players tag. (Admins only)', tag)
|
||||
commands.add_command("follow", '<player> makes you follow the player. Use /unfollow to stop following a player.', follow)
|
||||
commands.add_command("unfollow", 'stops following a player.', unfollow)
|
||||
commands.add_command("tpmode", "Toggles tp mode. When on place a ghost entity to teleport there (Admins and moderators)", toggle_tp_mode)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
local Event = {}
|
||||
|
||||
local debug_mode = false
|
||||
|
||||
local init_event_name = -1
|
||||
local load_event_name = -2
|
||||
|
||||
@@ -13,7 +11,7 @@ local event_handlers = {}
|
||||
local on_nth_tick_event_handlers = {}
|
||||
|
||||
local function call_handlers(handlers, event)
|
||||
if debug_mode then
|
||||
if _DEBUG then
|
||||
for _, handler in ipairs(handlers) do
|
||||
handler(event)
|
||||
end
|
||||
|
||||
@@ -9,8 +9,14 @@ local click_handlers
|
||||
local close_handlers
|
||||
|
||||
function Gui.uid_name()
|
||||
if _DEBUG then
|
||||
-- https://stackoverflow.com/questions/48402876/getting-current-file-name-in-lua
|
||||
local filename = debug.getinfo(2, 'S').source:match('^.+/(.+)$'):sub(1, -5)
|
||||
return filename .. ',' .. Token.uid()
|
||||
else
|
||||
return tostring(Token.uid())
|
||||
end
|
||||
end
|
||||
|
||||
-- Associates data with the LuaGuiElement. If data is nil then removes the data
|
||||
function Gui.set_data(element, data)
|
||||
|
||||
Reference in New Issue
Block a user