Extend lua print()

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Gerkiz
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Nov 30, 2018 3:36 pm
Contact:

Extend lua print()

Post by Gerkiz »

Hello,

I currently have the following setup:
A Factorio server that prints out to stdout via lua print and a backend server that reads the stdout, processes it and delivers the result back to the server either via a silent-command or rcon.
But to spare all the connected players and the unneccessary messages via print that really shouldn't reach them, I was wondering if the lua print could be extended with a parameter that would allow one to specify to what client to send this message to.


This would allow me to print messages only to the servers stdout that the backend can parse and would stop the unneccessary messages to all the connected clients.
This can also be used for other scenarios where you intend to only print information to the servers console but wouldn't want to print it to all the connected clients.

Thank you in advance,
/Gerkiz
Last edited by Gerkiz on Tue Oct 10, 2023 11:57 am, edited 1 time in total.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: extend LuaGameScript::print()

Post by Bilka »

What's the reason why you don't use write_file?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Gerkiz
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Nov 30, 2018 3:36 pm
Contact:

Re: extend LuaGameScript::print()

Post by Gerkiz »

Bilka wrote:
Fri Oct 06, 2023 2:37 pm
What's the reason why you don't use write_file?
The reason is simple, the requests are so fast-paced and are often many request and that would "wear/tear?" the disk, so I thought instead of doing that I could do it via print since print does not save to disk.

User avatar
atomizer
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Sep 22, 2018 3:18 pm
Contact:

Re: extend LuaGameScript::print()

Post by atomizer »

Gerkiz wrote:
Fri Oct 06, 2023 2:41 pm
Bilka wrote:
Fri Oct 06, 2023 2:37 pm
What's the reason why you don't use write_file?
The reason is simple, the requests are so fast-paced and are often many request and that would "wear/tear?" the disk, so I thought instead of doing that I could do it via print since print does not save to disk.
You could try using a named pipe to avoid writing a real file.

User avatar
Gerkiz
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Nov 30, 2018 3:36 pm
Contact:

Re: extend LuaGameScript::print()

Post by Gerkiz »

atomizer wrote:
Fri Oct 06, 2023 5:43 pm
Gerkiz wrote:
Fri Oct 06, 2023 2:41 pm
Bilka wrote:
Fri Oct 06, 2023 2:37 pm
What's the reason why you don't use write_file?
The reason is simple, the requests are so fast-paced and are often many request and that would "wear/tear?" the disk, so I thought instead of doing that I could do it via print since print does not save to disk.
You could try using a named pipe to avoid writing a real file.
I'll probably do just this. Thank you!

User avatar
Gerkiz
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Fri Nov 30, 2018 3:36 pm
Contact:

Re: extend LuaGameScript::print()

Post by Gerkiz »

To fill in on this, apparently I've totally looked up the wrong print function. I apologize for the misleading information.

I've previously mentioned that I would like for the LuaGameScript::print to be extended. But it's not correct one that I initially thought about.

This is the print function that I would like to get extended.
https://lua-api.factorio.com/latest/aux ... A2-print()

Post Reply

Return to “Modding interface requests”