Page 1 of 1
[0.18.8] game.print() adds extra spaces after "\n"
Posted: Mon Mar 02, 2020 12:08 am
by eradicator
What?
When using game.print (or player.print) to print a plain string that contains newlines ('\n') then four extra spaces are added after each newline.
Here's an example of string-with-newline vs for-looped-print:
Code: Select all
/c x = {'One','Two','Three','Four'} game.print(table.concat(x,'\n'))
/c x = {'One','Two','Three','Four'} for _,v in pairs(x) do game.print(v) end

- extraindent.png (332.56 KiB) Viewed 1640 times
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Thu Mar 05, 2020 11:19 am
by boskid
From what i see, it is not a bug. Every console item goes through wrapping that changes message into multiple lines and every line after first is then indented with width equivalent of 4 spaces. newline simply forces console item to be split into multiple lines.
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Thu Mar 05, 2020 6:27 pm
by eradicator
That is rather unfortunate. I guess i'll have to go ahead and write a function that splits strings with '\n' and then calls print multiple times to avoid the wrapping. ~.~
Thanks for having a look.
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Fri Mar 06, 2020 3:40 pm
by Rseding91
Or, just don't. Because then all of your messages will be inconsistent with how every other wrapped message works in the game.
When any message gets wrapped that's what happens to it in the output chat section. You can see it happen with the results of the /help command as well. Doing extra work to make your mod output *not* follow the standard method of line wrapping in chat output will just make your mod stick out as broken.
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Fri Mar 06, 2020 5:18 pm
by eradicator
Rseding91 wrote: Fri Mar 06, 2020 3:40 pm
Or, just don't. Because then all of your messages will be inconsistent with how every other wrapped message works in the game.
When any message gets wrapped that's what happens to it in the output chat section. You can see it happen with the results of the /help command as well. Doing extra work to make your mod output *not* follow the standard method of line wrapping in chat output will just make your mod stick out as broken.
Install /sudo. Type /sudo help create. Then we talk again. Oh, and btw tooltips have the opposite brokenness, they lack indentation. But with that kind of reaction i'm not even gonna bother to write an extra post for it. *sigh*
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Fri Mar 06, 2020 6:00 pm
by Rseding91
eradicator wrote: Fri Mar 06, 2020 5:18 pm
Rseding91 wrote: Fri Mar 06, 2020 3:40 pm
Or, just don't. Because then all of your messages will be inconsistent with how every other wrapped message works in the game.
When any message gets wrapped that's what happens to it in the output chat section. You can see it happen with the results of the /help command as well. Doing extra work to make your mod output *not* follow the standard method of line wrapping in chat output will just make your mod stick out as broken.
Install /sudo. Type /sudo help create. Then we talk again. Oh, and btw tooltips have the opposite brokenness, they lack indentation. But with that kind of reaction i'm not even gonna bother to write an extra post for it. *sigh*
The output of anything outside Factorio is irrelevant and I couldn't possibly care less how it works. Factorio chat output is what i'm talking about here.
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Sat Mar 07, 2020 2:11 am
by Jap2.0
Rseding91 wrote: Fri Mar 06, 2020 6:00 pm
eradicator wrote: Fri Mar 06, 2020 5:18 pm
Rseding91 wrote: Fri Mar 06, 2020 3:40 pm
Or, just don't. Because then all of your messages will be inconsistent with how every other wrapped message works in the game.
When any message gets wrapped that's what happens to it in the output chat section. You can see it happen with the results of the /help command as well. Doing extra work to make your mod output *not* follow the standard method of line wrapping in chat output will just make your mod stick out as broken.
Install /sudo. Type /sudo help create. Then we talk again. Oh, and btw tooltips have the opposite brokenness, they lack indentation. But with that kind of reaction i'm not even gonna bother to write an extra post for it. *sigh*
The output of anything outside Factorio is irrelevant and I couldn't possibly care less how it works. Factorio chat output is what i'm talking about here.
I believe he's referring to
https://mods.factorio.com/mod/eradicators-sudo.
Re: [0.18.8] game.print() adds extra spaces after "\n"
Posted: Sat Mar 07, 2020 7:43 am
by eradicator
I am indeed. And the "let's treat automatic linebreaks the same as manual ones" is what's making the formatting difficult. But anyway the thread was moot by the time @boskid was so nice to confirm that it's on purpose. And i have no clue what @Rsedind even intended to achive by telling me i'm doing things wrong without even knowing what the output is.