Page 1 of 1
Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?
Posted: Fri Oct 08, 2021 11:39 am
by thesixthroc
I recently released a softmod (a multiplayer scenario with no mods) that uses custom sprites. I call rendering.draw_sprite, with
Code: Select all
sprite = "file/maps/pirates/images/comfy2.png"
This works for me, but I now realise this uses Unix directory notation, not Windows. How do I detect if a player is on Unix or Windows?
Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?
Posted: Fri Oct 08, 2021 11:51 am
by Bilka
You can use "/" as the directory separator on all operating systems, when loading the sprite the game will covert it to the appropriate separator if needed.
Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?
Posted: Fri Oct 08, 2021 11:56 am
by thesixthroc
Hmm. Windows players crashed — only sometimes — when joining the scenario, with crash logs:
00007FFCA5D62651 (ntdll): (filename not available): RtlUserThreadStart
Stack trace logging done
32.504 Error SpriteDrawOrder.cpp:72: Invalid sprite reference. Sprite: C:\Users\Big_pc\AppData\Roaming\Factorio\temp\currently-playing\maps/pirates/images/tooltip-category-electricity2.png {x = 0, y = 0, w = 31, h = 38}, 0x00000163f3de8710
Tentatively, it looks as though putting the custom sprites in the root scenario directory, hence avoiding the '/' appearing above, solves the issue.
Or perhaps this is a caching issue, regarding 'currently-playing'? But my Windows playtester is reporting the issue is fixed with the above change. Again, this is tentative, I don't feel I have control over reproducibility of the problem yet. But hopefully I can proceed on this basis, although it would be nice to support subfolders...
Perhaps custom sprites in unmodded scenarios mods are not yet entirely supported?
Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?
Posted: Fri Oct 08, 2021 12:05 pm
by Bilka
If the game crashes, as in "An unexpected error occurred", post in
viewforum.php?f=7 (with the info requested in the pinned thread there). Mods should not be able to cause unexpected errors.
Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?
Posted: Fri Oct 08, 2021 12:07 pm
by thesixthroc
I shall, thank you!