brettchalupa / sokoworld

Classic box pushing puzzler Sokoban (built in Rust with Macroquad)
https://brettchalupa.itch.io/sokoworld
Other
4 stars 0 forks source link

Support specifying custom asset path #43

Closed tylerdq closed 1 day ago

tylerdq commented 2 days ago

On Linux, after building I copied the sokoworld binary to /usr/bin/sokoworld and when I try to run the game I get the following error:

thread 'main' panicked at src/assets_path.rs:55:5:
asset path cannot be determined

Is it possible to configure the build to install the game data to another folder that the binary can reference at execution, or is it a hard requirement that the game needs to be executed from the distribution folder?

tylerdq commented 2 days ago

Possible duplicate of #24

tylerdq commented 2 days ago

BrogueCE is another project that provides a nice solution to a similar challenge (although that game is written in C not Rust): https://github.com/tmewett/BrogueCE/blob/master/linux/brogue-multiuser.sh

brettchalupa commented 2 days ago

@tylerdq this makes sense and seeing the BrogueCE implementation helps. What would be your ideal way to configure this? Would an ENV var work? SOKOWORLD_ASSETS=/some/path Let me know how you'd expect this to be determined and I can implement it.

brettchalupa commented 2 days ago

I could also add a CLI arg for when the sokoworld executable is run, something like sokoworld --assets=/some/path.

tylerdq commented 2 days ago

I was thinking a build option but an ENV var is good as well. If a CLI arg is preferable for you though that would work fine! For example, if it ends up being a CLI arg I'd just make an abbreviation for sokoworld on my end in my shell (fish).

tylerdq commented 2 days ago

After considering a build option further with reference to the cargo-build documentation I realize I don't actually understand how that could be implemented. So one of the two solutions you suggested would probably work best.

brettchalupa commented 1 day ago

@tylerdq I added support for this in https://github.com/brettchalupa/sokoworld/pull/44, which merged into main and will be in the next release (v0.3.0). I tested it a bit locally, and both the env var SOKOWORLD_ASSETS and the --assets CLI arg are working as expected. It's kind of a nice feature in that it allows someone to mod the game, add custom levels, change the sprites, etc.

You should be able to run it now like this:

/usr/bin/sokoworld --assets ~/.local/bin/sokoworld/assets

Or wherever you want to put things. Let me know if you run into any issues!

tylerdq commented 1 day ago

Very nice. I rebuilt and both of these approaches work for me. I'm having issues actually playing it due to an unrelated issue with alsa but I need to investigate that more to see if something is misconfigured on my system.

Thank you!