this post was submitted on 23 Sep 2023
16 points (100.0% liked)

Godot

6022 readers
33 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

My game has options for player customization, it's a number of .png files that are not loaded with the game startup, save for the default ones. Instead, if the player clicks a button, it will load the next file for that part (like, say, hair-2.png)

This works fine on the editor, but I've just tested an exported version and it doesn't work there, completely failing to find any files within the .pck. If I move the executable back to the project's folder, it works as expected.

Trying to figure out the why, I've also exported via Export ZIP/PCK, and found out it doesn't actually export any of the .png files, it only exports the .import files. The actual images are stored in the .godot/imported folder, each with a long, random(?) string attached to their name: hair-1.png becomes hair-1.png-t3g9r2he7783y9hut.tcex

I haven't figured out a way to export the .png files as is, so what are my options here? Besides coupling all of the parts in a single image and separating it by frames of animation, which will require both code and art rework

Tested on both Godot 4.1.1 and 4.1.2-RC1

top 1 comments
sorted by: hot top controversial new old
[–] ICastFist@programming.dev 3 points 1 year ago

Ok, I figured out the problem and the solution:

  • My code was checking for and counting the .png files specifically: if FileAccess.file_exists(path+".png"): return load(path+".png")
  • As that actual file won't exist in an exported game, checking for the .import instead returns true on an exported project: if FileAccess.file_exists(path+".png.import"):
  • As the .import file also points to the correct resource, load(path+".png") still works

So, all I had to do was add ".import" to the checks of whether the file exists and everything worked. The idea to test that came after reading this issue *(plus another one I closed and can't find anymore) *and before I myself opened an issue complaining about the above. - https://github.com/godotengine/godot/issues/39746