Someone please explain me how to properly use multiple istances of Resources

Godot Version

4.4.1

I don’t understand how to do it from the docs.

In my 1st game (eye of the beerholder), i dealt with several types of damages as well as characters stats using standard arrays.
To make things more readable, instead of using simple numbers, I used enums to give a “name” to various things.

So for example I had an enum for damage_types that contained physical, fire, magic, etc.
So I ended up having something like damage[damage_type.fire] which is much easier to understand than damage[2], say.

Now I wanted to do more or less the same thing for damage and players/enemies stats, but using resources.
And in a deeper way.

Here is what I am using:

first I have a structure that extends node (because I tried doing it extending resources and I had trouble, ugh):

extends Node

class_name damage

@export var physical: damage_with_damaging_status_ailment 
@export var magic: damage_with_nerfing_status_ailment 
@export var fire: damage_with_damaging_status_ailment 
@export var ice: damage_with_nerfing_status_ailment 
@export var bolt: damage_with_nerfing_status_ailment
@export var poison: damage_with_damaging_status_ailment 
var total_damage: Array = []

var damage_colors: Array = [
	Color(0.75, 0.75, 0.75),
	Color(1,0,1),
	Color(1,0,0),
	Color(0,0.2,1),
	Color(1,1,0),
	Color(0,1,0)
	]

func _ready() -> void:
	total_damage = [
		physical,
		magic,
		fire,
		ice,
		bolt,
		poison
	]
	if total_damage[0] == null:
		total_damage[0] = load("res://scenes/weapons/damage_with_damaging_status_ailment.gd").new()
	if total_damage[2] == null:
		total_damage[2] = load("res://scenes/weapons/damage_with_damaging_status_ailment.gd").new()
	if total_damage[5] == null:
		total_damage[2] = load("res://scenes/weapons/damage_with_damaging_status_ailment.gd").new()
	if total_damage[1] == null:
		total_damage[1] = load("res://scenes/weapons/damage_with_nerfing_status_ailment.gd").new()
	if total_damage[3] == null:
		total_damage[3] = load("res://scenes/weapons/damage_with_nerfing_status_ailment.gd").new()
	if total_damage[4] == null:
		total_damage[4] = load("res://scenes/weapons/damage_with_nerfing_status_ailment.gd").new()
	

And here is what the two types of damage look like:

extends Resource
class_name damage_with_damaging_status_ailment

@export var damage_min: float = 0
@export var damage_max: float = 0
@export var chance_of_status_ailment: float = 0
@export var status_ailment_damage_multiplier: float = 2
@export var status_ailment_duration: int = 2

and:

extends Resource
class_name damage_with_nerfing_status_ailment

@export var damage_min: float = 0
@export var damage_max: float = 0
@export var chance_of_status_ailment: float = 0
@export var status_ailment_duration: int = 2

Problem is, seems like a resource is actually… well, one of its kind.

What I mean is that if I make a change in node A, which should have its “copy” of the resource, the change affects node B too.
Using “duplicate(true)” on the total_damage array does not work.

What should I do to get single copies of everything?

You’re supposed to create these resources once you created the “model” for them. Create a folder in your project where you’ll store your resources, then right click (inside that folder, inside godot), select Create, and pick Resource, then select the name of the resource you made. Call it something you want, then edit it.
Then you can do the same again later on, and at any point in your game you can use the resource loader to load these resources.