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
[15.34]Error printing tables. Repeatable. Any mods. Any save
- Bigfootmech
- Burner Inserter
- Posts: 18
- Joined: Wed Oct 11, 2017 8:06 pm
- Contact:
[15.34]Error printing tables. Repeatable. Any mods. Any save
- Attachments
-
- factorio-15.XX.log
- (3.77 KiB) Downloaded 96 times
-
- game.player.print(game.player.cursor_stack.get_blueprint_entities()[1].position) with blueprint in hand
- experimental_print_long.png (3.71 MiB) Viewed 1879 times
-
- game.player.print(game.player)
- experimental_print.png (3.94 MiB) Viewed 1879 times
-
- print_long.png (3.21 MiB) Viewed 1879 times
-
- print player.png (3.16 MiB) Viewed 1879 times
-
- factorio-15.37.log
- (18.39 KiB) Downloaded 94 times
-
- factorio-15.34.log
- (4.47 KiB) Downloaded 96 times
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [15.34]Error printing tables. Repeatable. Any mods. Any save
Use /c game.player.print(serpent.line(game.player, {comment = false})) instead. I guess you're right about that it still shouldn't throw an error though.
Edit: Corrected typo in command.
Edit: Corrected typo in command.
Last edited by eradicator on Wed Oct 18, 2017 8:27 am, edited 1 time in total.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [15.34]Error printing tables. Repeatable. Any mods. Any save
Thanks for the report. I've changed it so it won't give that specific error - but it's still going to error and state that you can't print LuaObjects. Additionally tables aren't printable unless you convert them into a string first.
If you want to get ahold of me I'm almost always on Discord.
- Bigfootmech
- Burner Inserter
- Posts: 18
- Joined: Wed Oct 11, 2017 8:06 pm
- Contact:
Re: [15.34]Error printing tables. Repeatable. Any mods. Any save
@eradicator
Tried the command, but it didn't work off the bat. I've seen serpent, but couldn't make heads or tails of it (maybe it's an ouroboros). Any case, I've read other stuff to the effect of "don't rely on player being static" or something. So I'm working with that. I also have a... let's say interesting library written now. It makes lua a lot more statically typed >.<
@Rseding91
Awesome! Thank you
Tried the command, but it didn't work off the bat. I've seen serpent, but couldn't make heads or tails of it (maybe it's an ouroboros). Any case, I've read other stuff to the effect of "don't rely on player being static" or something. So I'm working with that. I also have a... let's say interesting library written now. It makes lua a lot more statically typed >.<
@Rseding91
Awesome! Thank you
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [15.34]Error printing tables. Repeatable. Any mods. Any save
Oops. One of the brackets was in the wrong place. I edited the above post to the correct version. You won't get much useful out of printing the player object though as it is not a classic lua table. Not sure what you mean with player being non-static. "game.player" is a shortcut that only works on the ingame console and references the LuaPlayer object of whoever typed the command. You can't use it in a mod directly, it's only good for debugging/testing.Bigfootmech wrote:@eradicator
Tried the command, but it didn't work off the bat. I've seen serpent, but couldn't make heads or tails of it (maybe it's an ouroboros). Any case, I've read other stuff to the effect of "don't rely on player being static" or something. So I'm working with that. I also have a... let's say interesting library written now. It makes lua a lot more statically typed >.<
Also no clue why you would want to "make lua more statically typed". Performance is an issue so you shouldn't go too far with abstractions. If you need further help making your mod (assuming you are making one )... make a post in the modding help forum ^^, in here nobody else would find the posts if they had similar questions.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.