Saving weapons data using Resources. Good or Bad ? Alternatives ?

Godot Version

4.5.1

Question

Saving weapons data using Resources. Good or Bad ? Alternatives ?

  1. I wanted to save my weapons data as tres files with one resource file telling what fields should exist (as pasted in the code below)
  2. My problem is the readability of resource files compared to CSV or TXT files, where you can see all fields for all weapons in one go, whereas in resources you open each individually.
  3. Even tho i am using Resources as tables addon, reading array and dictionary is still hard.
  4. Maybe just me cause i just started, but i lost some of my data in the resource file ( it reverted back to default values instead of ones i put). it was working for a few days, but suddenly today data is back to default. I feel like CSV or TXT would have avoided that.

So are resources worth it, am i using them right , any alternatives ?

# sample of the resource file
extends Items
class_name Weapons

@export var base_damage:float
# Light attack combo
@export var attack_animations: Array[String]
@export var attack_damages: Array[float]

# Heavy attack combo
@export var heavy_attack_animations: Array[String]
@export var heavy_attack_damages: Array[float]

Do you use git? If yes, this shouldn’t be a problem. If no, you should start using it. Resources don’t just revert to default by their own, you must have done something that triggered it.

In general, Resources are perfectly fine for storing data, they are designed specifically for that purpose.

CSV or JSON are good alternatives too. They have their own advantages and disadvantages, there is no one answer fits all, it’s up to you which one you prefer.

1 Like

I have found it useful include default values in my resource class scripts, that way if I change a resource definition during development any new properties that may not be present in previously saved .tres files will have at least a sensible start value.

These default values eg. setting the attack_animations to [“Thrust”, “Slash”, “Stab”] have also made me more formal about creating any new models as I now have some naming conventions to adhere to.

1 Like

I use resources to store weapons data.

Your argument for the readability of those formats over the readability of resources doesn’t seem to account for the data being hard to see in one go when it is stored in different files, regardless of the format the data is in.

I keep the instances of my resources in a single file. Makes it easy to see and update.

As for your data reverting, that is a problem that can occur regardless of file format. As @wchc mentioned, a change control system is very helpful you make that sort of mistake.

1 Like