1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-09-16 09:06:21 +02:00

update debug func

This commit is contained in:
Gerkiz
2019-10-26 00:05:52 +02:00
parent a8aca84012
commit d83bcd3186
3 changed files with 77 additions and 3 deletions

View File

@@ -76,7 +76,6 @@ function Public.show(container)
end end
local right_panel = main_flow.add {type = 'text-box', name = right_panel_name} local right_panel = main_flow.add {type = 'text-box', name = right_panel_name}
right_panel.word_wrap = true
right_panel.read_only = true right_panel.read_only = true
right_panel.selectable = true right_panel.selectable = true

View File

@@ -1,9 +1,15 @@
local DebugView = require 'utils.debug.main_view' local DebugView = require 'utils.debug.main_view'
local Model = require 'model'
local loadstring = loadstring
local pcall = pcall
local dump = Model.dump
local log = log
commands.add_command( commands.add_command(
'debug', 'debug',
'Opens the debugger', 'Opens the debugger',
function(_, player) function(_)
local player = game.player local player = game.player
local p local p
if player then if player then
@@ -18,3 +24,72 @@ commands.add_command(
DebugView.open_dubug(player) DebugView.open_dubug(player)
end end
) )
commands.add_command(
'dump-log',
'Dumps value to log',
function(args)
local player = game.player
local p
if player then
p = player.print
if not player.admin then
p('Only admins can use this command.')
return
end
else
p = player.print
end
if args.parameter == nil then return end
local func, err = loadstring('return ' .. args.parameter)
if not func then
p(err)
return
end
local suc, value = pcall(func)
if not suc then
p(value)
return
end
log(dump(value))
end
)
commands.add_command(
'dump-file',
'Dumps value to dump.lua',
function(args)
local player = game.player
local p
if player then
p = player.print
if not player.admin then
p('Only admins can use this command.')
return
end
else
p = player.print
end
if args.parameter == nil then return end
local func, err = loadstring('return ' .. args.parameter)
if not func then
p(err)
return
end
local suc, value = pcall(func)
if not suc then
p(value)
return
end
value = dump(value)
game.write_file('dump.lua', value, false)
end
)

View File

@@ -71,7 +71,6 @@ local function inspect_process(item)
return concat(luaEntity) return concat(luaEntity)
elseif obj_type == 'LuaGuiElement' then elseif obj_type == 'LuaGuiElement' then
local name = item.name local name = item.name
if luaGuiElement[2] == nil then return end
luaGuiElement[2] = gui_names[name] or name or 'nil' luaGuiElement[2] = gui_names[name] or name or 'nil'
return concat(luaGuiElement) return concat(luaGuiElement)
@@ -88,6 +87,7 @@ function Public.dump(data)
return inspect(data, inspect_options) return inspect(data, inspect_options)
end end
local dump = Public.dump local dump = Public.dump
_G.dump = dump
function Public.dump_ignore_builder(ignore) function Public.dump_ignore_builder(ignore)
local function process(item) local function process(item)