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.scenario = {}
|
||||||
global.spys = {"valansch", "air20"}
|
global.spys = {"valansch", "air20"}
|
||||||
global.scenario.variables = {}
|
global.scenario.variables = {}
|
||||||
|
|||||||
@@ -448,14 +448,16 @@ local function pool()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_add_command = commands.add_command
|
if not _DEBUG then
|
||||||
commands.add_command = function(name, desc, func)
|
local old_add_command = commands.add_command
|
||||||
old_add_command(name, desc, function(cmd)
|
commands.add_command = function(name, desc, func)
|
||||||
local success, error = pcall(func, cmd)
|
old_add_command(name, desc, function(cmd)
|
||||||
if not success then
|
local success, error = pcall(func, cmd)
|
||||||
log(error)
|
if not success then
|
||||||
end
|
log(error)
|
||||||
end)
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
commands.add_command("kill", "Will kill you.", kill)
|
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("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("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("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("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("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)
|
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 Event = {}
|
||||||
|
|
||||||
local debug_mode = false
|
|
||||||
|
|
||||||
local init_event_name = -1
|
local init_event_name = -1
|
||||||
local load_event_name = -2
|
local load_event_name = -2
|
||||||
|
|
||||||
@@ -13,7 +11,7 @@ local event_handlers = {}
|
|||||||
local on_nth_tick_event_handlers = {}
|
local on_nth_tick_event_handlers = {}
|
||||||
|
|
||||||
local function call_handlers(handlers, event)
|
local function call_handlers(handlers, event)
|
||||||
if debug_mode then
|
if _DEBUG then
|
||||||
for _, handler in ipairs(handlers) do
|
for _, handler in ipairs(handlers) do
|
||||||
handler(event)
|
handler(event)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ local click_handlers
|
|||||||
local close_handlers
|
local close_handlers
|
||||||
|
|
||||||
function Gui.uid_name()
|
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
|
end
|
||||||
|
|
||||||
-- Associates data with the LuaGuiElement. If data is nil then removes the data
|
-- Associates data with the LuaGuiElement. If data is nil then removes the data
|
||||||
|
|||||||
Reference in New Issue
Block a user