Page 1 of 1

[0.12.35] Unexpected code behaviour

Posted: Sat Jun 18, 2016 9:59 pm
by Killkrog
Hi!

In a vanilla game, i have a mod with this code:

Code: Select all

for _, recipe in pairs(game.player.force.recipes) do
	if #(recipe.products) > 1 then
		game.player.print(recipe.name)
		for _, product in pairs(recipe.products) do
			game.player.print(product.name)
		end
	end
end
Expected output:
basic-oil-processing
heavy-oil
light-oil
petroleum-gas
advanced-oil-processing
heavy-oil
light-oil
petroleum-gas
empty-cude-oil-barrel
empty-barrel
crude-oil

Actual output:
basic-oil-processing
heavy-oil
light-oil
petroleum-gas
advanced-oil-processing
<missing output here>
empty-cude-oil-barrel
empty-barrel
crude-oil

What do I do wrong?

Thanks for your help =)

Re: [0.12.35] Unexpected code behaviour

Posted: Sat Jun 18, 2016 10:34 pm
by DaveMcW
There is a flood filter on player.print(), you can only print the same line once per second.

I find it easier to debug stuff using game.write_file(file, string, true)

Re: [0.12.35] Unexpected code behaviour

Posted: Sat Jun 18, 2016 10:37 pm
by Killkrog
*bows respectfully*

Thank you!

Re: [0.12.35] Unexpected code behaviour

Posted: Sat Jun 18, 2016 10:57 pm
by orzelek
There is also log() which can be used on data stage and dumps stuff to game log directly.