Print to game console during on_init?

Place to get help with not working mods / modding interface.
Post Reply
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2712
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Print to game console during on_init?

Post by FuryoftheStars »

Is it possible to print a message out to the console in game during the on_init event?

game.print(message) doesn't actually seem to output anything during this event. I know the function I've assigned to it is firing because a log(message) in the same function does output to the log. It's just that sometimes it's easier to get needed debugging output from right within the game vs alt+tabbing -> reload file -> scroll scroll scroll (especially when trying to test compatibility with other mods that are outputting to the log as well).
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics

lyvgbfh
Fast Inserter
Fast Inserter
Posts: 165
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: Print to game console during on_init?

Post by lyvgbfh »

FuryoftheStars wrote:
Fri Feb 24, 2023 3:49 am
Is it possible to print a message out to the console in game during the on_init event?

game.print(message) doesn't actually seem to output anything during this event. I know the function I've assigned to it is firing because a log(message) in the same function does output to the log. It's just that sometimes it's easier to get needed debugging output from right within the game vs alt+tabbing -> reload file -> scroll scroll scroll (especially when trying to test compatibility with other mods that are outputting to the log as well).
It won't solve your question, but I use logexpert (or `tail` on linux) to watch the game log if I'm debugging and don't have factorio launching with the dedicated console window in the background. I would recommend it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1664
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Print to game console during on_init?

Post by Pi-C »

FuryoftheStars wrote:
Fri Feb 24, 2023 3:49 am
Is it possible to print a message out to the console in game during the on_init event?

game.print(message) doesn't actually seem to output anything during this event.
I think it is possible if there are players in the game. This would be the case in single player mode when on_init is run because your mod has been added to a running game. It wouldn't work when you start a new game (there is no player yet that could see the message), and it shouldn't work in multiplayer mode (because on_init will run before on_player_joined_game).
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2712
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Print to game console during on_init?

Post by FuryoftheStars »

Crap, I was afraid that was what it was going to come around to. Alright, thanks.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics

Post Reply

Return to “Modding help”