I am trying to work on a save system, and the Resource saver doesn't work for me because I have custom resources nested inside custom resources. So I'm trying to work on saving the resources to JSON, but one of my custom resources has an item icon property that is a texture. How can I save the texture to a json friendly format and then get it back again from the json string?
#Store Texture to JSON friendly string and back again?
18 messages · Page 1 of 1 (latest)
Do you really need to store the texture itself into the JSON? Why can't you just store the file path? Or even just some kind of identifier?
I need to be able to associate it with the "item" that a player has in their inventory. So I'm going through each "item data" custom resource and converting their properties (name, description, gold value, and the texture (the item icon) to json friendly string to be able to load it back up from a save file.
So yeah, just store the file path to the texture
Although I'm not sure why you can't use resources normally for this
I feel like you might be going down a weird path instead of just simplifying things
Can I get the file path from a custom resource's item icon property?
I've tried doing Resource saver, but it doesn't work if you have custom resources nested inside custom resources
I feel like it should
You would think!
Are you sure you aren't doing it wrong?
Not 100%, but there is a bug I found on the godot github page that seems to confirm it is an issue.
I feel like you shouldn't need to store a texture or an icon or anything. Why can't you just store some kind of ID of the type of item?
I can rework my item system to probably do something like that. Was just trying to avoid it.
Like if you're just saving the player's inventory, you shouldn't need to save most of that data at all. You don't need to save name, description, value, etc. That's not relevant to the save itself. You just need to save the type of item and the quantity
In fact you shouldn't save that. What if you need to modify the description in the future because of a typo, or you rename something, or change an icon? Suddenly the save file is using old, irrelevant data
Hmmm. That's a good point.
I followed this tutorial:
https://www.youtube.com/watch?v=V79YabQZC1s
To set up my inventory system.
Which seems great. But saving the inventory state for the player? Being able to have multiple characters each with their own inventory and trying to be able to save everything? Not so much.
Basic FPS Controller Code: https://pastebin.com/yJwwpkCu
Shikashi's Fantasy icons Pack: https://cheekyinkling.itch.io/shikashis-fantasy-icons-pack
Follow along as I code the structure of an RPG type inventory system in Godot 4.
=== Intro / Setup ===
0:00 Intro
0:45 Project Setup
=== Resource Data Structure ===
2:50 Item Data Resource
4:27 Slo...
I figure I'm probably just missing something vital. I just started learning Godot, so I'm missing a lot of info.
I really appreciate you taking the time to reply! Thanks a bunch!