Page 1 of 1

game.take_screenshot mapshot and working with headless

Posted: Wed Oct 21, 2020 6:25 pm
by LuziferSenpai
Hey,

it would be awesome to have the option to the screenshot the map itself and do that on a headless server, because for Community Events like Red-Circuit's Molten Silicon we would love to beable to just screenshot every x seconds the 2k x 2k map with the custom scenario, that I created.

Greetz,

Luzifer

Re: game.take_screenshot mapshot and working with headless

Posted: Wed Oct 21, 2020 8:24 pm
by Rseding91
This isn't going to happen. The headless version of the game does not ship with any graphics logic enabled and so can't do anything with graphics.

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 8:37 am
by LuziferSenpai
But why then not allow us to give a player_id and then take the screenshot from the player's client? That would go around the graphic problem.
And the map view screenshot option would still be awesome, either way.

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 8:44 am
by boskid
https://lua-api.factorio.com/1.0.0/LuaG ... screenshot
by_player :: PlayerSpecification (optional): If defined, the screenshot will only be taken for this player.

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 5:53 pm
by LuziferSenpai
boskid wrote:
Thu Oct 22, 2020 8:44 am
https://lua-api.factorio.com/1.0.0/LuaG ... screenshot
by_player :: PlayerSpecification (optional): If defined, the screenshot will only be taken for this player.
But does that already work on headless?

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 5:58 pm
by boskid
No, it does not work on headless because headless never renders anything. For screenshots you need a fully capable client with graphics. You may solve this for example by having your own delegated client called "i_am_for_screenshots" that is under your control and have a game script that calls take_screenshot with by_player="i_am_for_screenshots". That way headless will host a game and delegated client will render screenshots.

per force charts are rendered by headless on a chunk-base since they are part of game state and are delivered in saves to connecting clients. Even with this in mind i would not let headless to be able to take any screenshots to a file.

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 7:26 pm
by LuziferSenpai
boskid wrote:
Thu Oct 22, 2020 5:58 pm
No, it does not work on headless because headless never renders anything. For screenshots you need a fully capable client with graphics. You may solve this for example by having your own delegated client called "i_am_for_screenshots" that is under your control and have a game script that calls take_screenshot with by_player="i_am_for_screenshots". That way headless will host a game and delegated client will render screenshots.

per force charts are rendered by headless on a chunk-base since they are part of game state and are delivered in saves to connecting clients. Even with this in mind i would not let headless to be able to take any screenshots to a file.
Yea, the player is not the problem. What I mean is, that the info says it will not work on headless. So in the lua-api

Re: game.take_screenshot mapshot and working with headless

Posted: Thu Oct 22, 2020 9:29 pm
by eradicator
LuziferSenpai wrote:
Thu Oct 22, 2020 7:26 pm
that the info says it will not work on headless.
When you join a server with a standard graphical client then that graphical client is not running headless.

Re: game.take_screenshot mapshot and working with headless

Posted: Mon Nov 09, 2020 7:41 pm
by palats
Fwiw, it seems to work to run Factorio through Xvfb - thus in practice allowing to take screenshot from a headless server, as long as it is still a regular install of Factorio (not running Factorio in server mode though, which does not load graphics, headless or not).

Re: game.take_screenshot mapshot and working with headless

Posted: Mon Nov 09, 2020 10:06 pm
by Rseding91
Seems there's some confusion about what "headless" means in Factorio.

* The dedicated headless linux download: compiled with zero graphics - only runs the server.
* Any version of the game run with --start-server/variants: headless mode - no graphics are loaded/enabled.
* Any version of the game with graphics: *not* headless and can do things like take_screenshot.

You can connect any graphics-enabled version of the game to the headless version of the game. "headless" just means "running as a server without graphics". The graphics enabled versions of the game can use take_screenshot while connected to a headless server.