From bffdc34504c763bb58d3e4ff23d045c91457694e Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 22 Sep 2017 15:42:46 +0100 Subject: [PATCH] Added Bebug command --- locale/ExpGaming-Core/ExpGaming - Lib.lua | 7 +++++++ locale/ExpGaming-Core/ExpGaming - Server Interface.lua | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/locale/ExpGaming-Core/ExpGaming - Lib.lua b/locale/ExpGaming-Core/ExpGaming - Lib.lua index 08c97124..f42d9b67 100644 --- a/locale/ExpGaming-Core/ExpGaming - Lib.lua +++ b/locale/ExpGaming-Core/ExpGaming - Lib.lua @@ -72,5 +72,12 @@ function table.tostring( tbl ) end return "{" .. table.concat( result, "," ) .. "}" end +-- allows a simple way to debug code +function debug_write(idenitys,string) + if global.debug then + game.write_file('debug.log', '\n'..game.tick..' ['..table.concat(idenitys, " " )..'] '..string, true, 0) + end +end +Event.register(-1,function() global.debug = false end) --Please Only Edit Above This Line----------------------------------------------------------- return credits \ No newline at end of file diff --git a/locale/ExpGaming-Core/ExpGaming - Server Interface.lua b/locale/ExpGaming-Core/ExpGaming - Server Interface.lua index 6cf9dcc8..1a0b30d2 100644 --- a/locale/ExpGaming-Core/ExpGaming - Server Interface.lua +++ b/locale/ExpGaming-Core/ExpGaming - Server Interface.lua @@ -30,6 +30,14 @@ define_command('server-interface','For use of the highest staff only',{'command' else game.write_file('server-interface-players.log', '\n'..game.tick..' Ran by: '..player.name..' Code: '..event.parameter..'\nReturned: '..tostring(value), true, 0) player.print(tostring(value)) end end end) +--runs a server interface command with debug on and does not return any values to the user +define_command('debug','For use of the highest staff only',{'command',true},function(player,event,args) + global.debug = true + debug_write({'START'},game.tick) + pcall(loadstring(event.parameter)) + debug_write({'END'},game.tick) + global.debug = false +end) --this is used when changing permission groups when the person does not have permsion to, can also be used to split a large event accross multiple ticks local commands_per_iteration = 50 --number of sudo commands ran every sudo iteration local ticks_per_iteration = 1 --the number of ticks break before the next sudo iteration