Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?

Place to get help with not working mods / modding interface.
Post Reply
thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?

Post 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?

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

Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?

Post 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?

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

Re: Softmod — Detecting if a player is on Unix or Windows, for custom sprite path?

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.


Post Reply

Return to “Modding help”