Questionable game.player.print() optimizations.

Bugs that are actually features.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Questionable game.player.print() optimizations.

Post by Adil »

If the string passed to game.player.print() is the same as the one passed in previous call, it is not output. (Well, if typed manually, it is.)

Code: Select all

/c for _,i in pairs{0,0,0,0} do game.player.print(i); end
produces output
0
Is it really a reasonable behavior?
It raises problems for debugging when quickly checking a number of different variables:

Code: Select all

a=1; b=1; c=2; d=1;
game.player.print(a);
game.player.print(b);
game.player.print(c);
game.player.print(d);
1
2 <-which element is this?
1
or

Code: Select all

a=1; b=1;
game.player.print(a);
game.player.print(b);
a=a+b;
game.player.print(a);
game.player.print(b);
 
1
2
1
Such snippets are often temporarily placed in code just to check this or that (well, at least often placed by me), so typing any additional unique strings to identify what is that printed is not very handy. Positional identification on the other hand is cheap and quick way of achieving only slightly less degree of recognition of outputs.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Questionable game.player.print() optimizations.

Post by kovarex »

I understand it, but the mechanism is used to avoid spam of messages in certain situation (like full inventory, can't build etc).

You can always change the messages to contain unique number or something.
Post Reply

Return to “Not a bug”