Mandatory resource properties

Godot Version

v4.2.2.stable.official [15073afe3]

Question

Is there a way to require a resource’s property to be set by the developer?
In this example, how can I force a value other than 0 to be set by the developer to make the game start?
image

The reason I want this is because I want custom properties such as a class that contains an entire attack to be added into an array as a resource. But if the array is empty the character would not have any attack moves. If by testing I do not notice this issue, I might well ship my game without noticing one of the characters not working.
Yes, I could set a random attack as a default value, but that is not what I am looking for.

You can assert on _ready and/or make the resource a @tool script.

assert(attack_array != null and attack_array.size() > 0, "Attacks must be set!") 
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.