[0.12.35] Unexpected code behaviour

Place to get help with not working mods / modding interface.
User avatar
Killkrog
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Thu Jun 09, 2016 1:04 pm
Contact:

[0.12.35] Unexpected code behaviour

Post 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 =)
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: [0.12.35] Unexpected code behaviour

Post 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)
User avatar
Killkrog
Long Handed Inserter
Long Handed Inserter
Posts: 75
Joined: Thu Jun 09, 2016 1:04 pm
Contact:

Re: [0.12.35] Unexpected code behaviour

Post by Killkrog »

*bows respectfully*

Thank you!
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.12.35] Unexpected code behaviour

Post by orzelek »

There is also log() which can be used on data stage and dumps stuff to game log directly.
Post Reply

Return to “Modding help”