I am trying to make a mod that is capable of taking screenshots of the game at regular intervals among other tasks.
I'm using the game.takescreenshot function and whenever the show_gui, show_entity_info, or show_cursor_building_preview are set to true the game crashes.
The error log looks oddly similar to the forum thread 52878.
I tried solutions from there like disabling all game overlays from third party apps, and forcing openGL. I also tried all the suggestions in the common graphics error thread. 9300
I'm not keen on calling this a bug because I am quite new to modding Factorio. As such I created a video showing the lines of code that produce the error. I think this may be a syntax issue that I'm not aware of but I've tried many fixes. Anyway, the video is here:
https://www.dropbox.com/scl/fi/k050mlyl ... mir2f&dl=0
[boskid][2.0.30] Crash taking screenshots via modding API, Optional.hpp check fails
[boskid][2.0.30] Crash taking screenshots via modding API, Optional.hpp check fails
- Attachments
-
- factorio-previous.log
- (11.22 KiB) Downloaded 10 times
Re: [2.0.30] Crash taking screenshots via modding API, Optional.hpp check fails
Welcome to the forum, and thank you for the report.
This doesn't look graphics related.
More like it's trying to take a screenshot in the zeroth tick after loading a save, during which some gui stuff is not ready yet.
So it crashes with
but doesn't crash with (yes, this may be not multiplayer safe)
This doesn't look graphics related.
More like it's trying to take a screenshot in the zeroth tick after loading a save, during which some gui stuff is not ready yet.
So it crashes with
Code: Select all
script.on_event(defines.events.on_tick, function(event)
if game.tick ~= 0 then
game.take_screenshot{
show_gui = true,
...
Code: Select all
local lasttick
script.on_event(defines.events.on_tick, function(event)
if not lasttick then
lasttick = game.tick
else
game.take_screenshot{
show_gui = true,
...
Re: [2.0.30] Crash taking screenshots via modding API, Optional.hpp check fails
Thank you so much! I knew it was probably my inexperience. It's okay that it's not multiplayer safe, it's just for collecting data.
Re: [2.0.30] Crash taking screenshots via modding API, Optional.hpp check fails
This issue should be now fixed for 2.0.31. When doing a screenshot for gui or for "building preview", the screenshot request was populated with cursor position however it look at this early stage it was not yet available and so it crashed trying to convert empty optional into a position.