mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-17 21:08:08 +02:00
added debug support
This commit is contained in:
parent
94f63f131d
commit
4c1892bc10
@ -1,3 +1,5 @@
|
||||
_DEBUG = false
|
||||
|
||||
global.scenario = {}
|
||||
global.spys = {"valansch", "air20"}
|
||||
global.scenario.variables = {}
|
||||
|
@ -448,14 +448,16 @@ local function pool()
|
||||
end
|
||||
end
|
||||
|
||||
local old_add_command = commands.add_command
|
||||
commands.add_command = function(name, desc, func)
|
||||
old_add_command(name, desc, function(cmd)
|
||||
local success, error = pcall(func, cmd)
|
||||
if not success then
|
||||
log(error)
|
||||
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)
|
||||
local success, error = pcall(func, cmd)
|
||||
if not success then
|
||||
log(error)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command("kill", "Will kill you.", kill)
|
||||
@ -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,7 +9,13 @@ local click_handlers
|
||||
local close_handlers
|
||||
|
||||
function Gui.uid_name()
|
||||
return tostring(Token.uid())
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user