diff --git a/locale/ExpGaming-Core/ExpGaming - Lib.lua b/locale/ExpGaming-Core/ExpGaming - Lib.lua index f42d9b67..98aaa713 100644 --- a/locale/ExpGaming-Core/ExpGaming - Lib.lua +++ b/locale/ExpGaming-Core/ExpGaming - Lib.lua @@ -75,6 +75,8 @@ end -- allows a simple way to debug code function debug_write(idenitys,string) if global.debug then + if type(string) == 'table' then string = table.tostring(string) + elseif tpye(string) ~= 'string' then string = tostring(string) end game.write_file('debug.log', '\n'..game.tick..' ['..table.concat(idenitys, " " )..'] '..string, true, 0) end end diff --git a/locale/ExpGaming-Core/ExpGaming - Server Interface.lua b/locale/ExpGaming-Core/ExpGaming - Server Interface.lua index 1a0b30d2..9b42618a 100644 --- a/locale/ExpGaming-Core/ExpGaming - Server Interface.lua +++ b/locale/ExpGaming-Core/ExpGaming - Server Interface.lua @@ -31,9 +31,9 @@ define_command('server-interface','For use of the highest staff only',{'command' 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) +define_command('debug','For use of the highest staff only, this will lag A LOT',{'command',true},function(player,event,args) global.debug = true - debug_write({'START'},game.tick) + debug_write({'START'},game.tick..' '..event.parameter) pcall(loadstring(event.parameter)) debug_write({'END'},game.tick) global.debug = false @@ -46,6 +46,7 @@ function sudo(command,args,custom_return_name) if type(command) == 'function' then local args = args or {} local return_name = custom_return_name or tostring(game.tick)..tostring(command)..tostring(#global.sudo.commands) + debug_write({'SUDO','ADD'},return_name) table.insert(global.sudo.commands,{fun=command,args=args,return_name=return_name}) refresh_temp_var(return_name,'temp-var-temp-value') return {sudo='sudo-temp-var',name=return_name} @@ -66,10 +67,10 @@ function refresh_temp_var(name,value,offset) end end -- gets the data stored in a temp varible -function get_temp_var_data(var) +function get_temp_var_data(var) local to_return = nil - if global.sudo.temp_varibles[var] then to_return = global.sudo.temp_varibles[var].data - elseif var.name and global.sudo.temp_varibles[var.name] then to_return = global.sudo.temp_varibles[var.name].data end + if global.sudo.temp_varibles[var] then to_return = global.sudo.temp_varibles[var].data debug_write({'SUDO','TEMP-VAR'},var) + elseif var.name and global.sudo.temp_varibles[var.name] then to_return = global.sudo.temp_varibles[var.name].data debug_write({'SUDO','TEMP-VAR'},var.name) end return to_return end -- returns the lenth of the temp varible list and command queue, is string is true then it is retured as a string @@ -86,6 +87,7 @@ end --sudo main loop Event.register(defines.events.on_tick, function(event) -- runs the commands in sudo + debug_write({'SUDO'},get_sudo_info(true)) if game.tick % ticks_per_iteration == 0 and global.sudo.commands and #global.sudo.commands > 0 then local length = nil if #global.sudo.commands > commands_per_iteration then length = commands_per_iteration else length = #global.sudo.commands end