mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Sudo debug added
This commit is contained in:
@@ -75,6 +75,8 @@ end
|
|||||||
-- allows a simple way to debug code
|
-- allows a simple way to debug code
|
||||||
function debug_write(idenitys,string)
|
function debug_write(idenitys,string)
|
||||||
if global.debug then
|
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)
|
game.write_file('debug.log', '\n'..game.tick..' ['..table.concat(idenitys, " " )..'] '..string, true, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ define_command('server-interface','For use of the highest staff only',{'command'
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
--runs a server interface command with debug on and does not return any values to the user
|
--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
|
global.debug = true
|
||||||
debug_write({'START'},game.tick)
|
debug_write({'START'},game.tick..' '..event.parameter)
|
||||||
pcall(loadstring(event.parameter))
|
pcall(loadstring(event.parameter))
|
||||||
debug_write({'END'},game.tick)
|
debug_write({'END'},game.tick)
|
||||||
global.debug = false
|
global.debug = false
|
||||||
@@ -46,6 +46,7 @@ function sudo(command,args,custom_return_name)
|
|||||||
if type(command) == 'function' then
|
if type(command) == 'function' then
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local return_name = custom_return_name or tostring(game.tick)..tostring(command)..tostring(#global.sudo.commands)
|
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})
|
table.insert(global.sudo.commands,{fun=command,args=args,return_name=return_name})
|
||||||
refresh_temp_var(return_name,'temp-var-temp-value')
|
refresh_temp_var(return_name,'temp-var-temp-value')
|
||||||
return {sudo='sudo-temp-var',name=return_name}
|
return {sudo='sudo-temp-var',name=return_name}
|
||||||
@@ -68,8 +69,8 @@ end
|
|||||||
-- gets the data stored in a temp varible
|
-- gets the data stored in a temp varible
|
||||||
function get_temp_var_data(var)
|
function get_temp_var_data(var)
|
||||||
local to_return = nil
|
local to_return = nil
|
||||||
if global.sudo.temp_varibles[var] then to_return = global.sudo.temp_varibles[var].data
|
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 end
|
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
|
return to_return
|
||||||
end
|
end
|
||||||
-- returns the lenth of the temp varible list and command queue, is string is true then it is retured as a string
|
-- 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
|
--sudo main loop
|
||||||
Event.register(defines.events.on_tick, function(event)
|
Event.register(defines.events.on_tick, function(event)
|
||||||
-- runs the commands in sudo
|
-- 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
|
if game.tick % ticks_per_iteration == 0 and global.sudo.commands and #global.sudo.commands > 0 then
|
||||||
local length = nil
|
local length = nil
|
||||||
if #global.sudo.commands > commands_per_iteration then length = commands_per_iteration else length = #global.sudo.commands end
|
if #global.sudo.commands > commands_per_iteration then length = commands_per_iteration else length = #global.sudo.commands end
|
||||||
|
|||||||
Reference in New Issue
Block a user