mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-16 08:24:52 +09:00
Refactor of commands
This commit is contained in:
1 parent
e547f76d6f
commit
62dcfe8694
288 files changed
+5364
-1067
No files matched your search
@@ -0,0 +1,32 @@
|
||||
-- A small debugging tool that writes the contents of _ENV to a file when the game loads.
|
||||
-- Useful for ensuring you get the same information when loading
|
||||
-- the reference and desync levels in desync reports.
|
||||
-- dependencies
|
||||
local table = require 'utils.table'
|
||||
local Event = require 'utils.event'
|
||||
|
||||
-- localized functions
|
||||
local inspect = table.inspect
|
||||
|
||||
-- local constants
|
||||
local filename = 'env_dump.lua'
|
||||
|
||||
-- Removes metatables and the package table
|
||||
local filter = function(item, path)
|
||||
if path[#path] ~= inspect.METATABLE and item ~= 'package' then
|
||||
return item
|
||||
end
|
||||
end
|
||||
|
||||
local function player_joined(event)
|
||||
local dump_string = inspect(_ENV, {process = filter})
|
||||
if dump_string then
|
||||
local s = string.format('tick on join: %s\n%s', event.tick, dump_string)
|
||||
game.write_file(filename, s)
|
||||
game.print('_ENV dumped into ' .. filename)
|
||||
else
|
||||
game.print('_ENV not dumped, dump_string was nil')
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, player_joined)
|
||||
Reference in new issue
Block a user