[15.34]Error printing tables. Repeatable. Any mods. Any save
Posted: Wed Oct 18, 2017 12:08 am
Also in 15.37 and 15.XX.
1. What did you do?
- Open console
- type (or paste) /c game.player.print(game.player)
- press enter
Bug is repeatable every time.
2. What happened?
Message displayed "Cannot execute command. Error: LuaPlayer doesn't contain key x. stack traceback: [C]: in function 'print' [string "game.player.print(game.player)"]:1:in main chunk
3. What did you expect to happen instead? It might be obvious to you, but do it anyway!
Message containing table: 0x00000000XXXXXXXX (lua behaviour), or printing of some info related to the object, such as type, or its contents.
4. Assumption
Someone made the print command try to print the "position" instead of a table
5. Investigation
With a blueprint in hand (with at least one entity), sending
/c game.player.print(game.player.cursor_stack.get_blueprint_entities()[1].position)
sides with the guess, as it prints {x = ..., y = ...}
6. Possible solution?
Recursively print tables
local function to_string(source)
if type(source) ~= "table" then return tostring(source) end -- tostring here accounts for userdata
local stringy = "{"
for k, v in pairs(source) do
stringy = stringy .. to_string(k) .. " = " .. to_string(v) .. ","
end
stringy = stringy:sub(1,-2) .. "}"
return stringy
end
Provide Attachments:
- log files X 3: Factorio 15.34, 15.37, and 15.XX (37) - with username scratched out for privacy
- save files: none necessary. Works on every save, or newly generated world (tested on multiple new worlds/saves).
- mods folder: unnecesary. Works with and without mods (tested).
- desync-report:none. Local used.
- Screenshots X 4
1. What did you do?
- Open console
- type (or paste) /c game.player.print(game.player)
- press enter
Bug is repeatable every time.
2. What happened?
Message displayed "Cannot execute command. Error: LuaPlayer doesn't contain key x. stack traceback: [C]: in function 'print' [string "game.player.print(game.player)"]:1:in main chunk
3. What did you expect to happen instead? It might be obvious to you, but do it anyway!
Message containing table: 0x00000000XXXXXXXX (lua behaviour), or printing of some info related to the object, such as type, or its contents.
4. Assumption
Someone made the print command try to print the "position" instead of a table
5. Investigation
With a blueprint in hand (with at least one entity), sending
/c game.player.print(game.player.cursor_stack.get_blueprint_entities()[1].position)
sides with the guess, as it prints {x = ..., y = ...}
6. Possible solution?
Recursively print tables
local function to_string(source)
if type(source) ~= "table" then return tostring(source) end -- tostring here accounts for userdata
local stringy = "{"
for k, v in pairs(source) do
stringy = stringy .. to_string(k) .. " = " .. to_string(v) .. ","
end
stringy = stringy:sub(1,-2) .. "}"
return stringy
end
Provide Attachments:
- log files X 3: Factorio 15.34, 15.37, and 15.XX (37) - with username scratched out for privacy
- save files: none necessary. Works on every save, or newly generated world (tested on multiple new worlds/saves).
- mods folder: unnecesary. Works with and without mods (tested).
- desync-report:none. Local used.
- Screenshots X 4