Godot 4.3 stable.
Hello everyone,
So I’m trying to code for a spell, where two of the variables are mana and sp_trsmog, and both will have their values be dependent on the enums spelllevel and trsmog_affinity.
the variable mana is set to be equal to whichever spell level (from the enum) multiplied by 10 and then plus 10. so if minor it will be 10 * 1 + 10 = 20
the variable sp_trsmog is set to be equal to whichever integers are set from trsmog_affinity and spelllevel multiplied by each other. so if minor and strong will be 1 * 3 = 3
However, this way of going about it doesn’t seem to work and I don’t understand why exactly. It just has mana = to 10 and sp_trsmog = 0, which makes me think it is a bug since I had mana = 10 as the default while I was figuring out the basic spell mechanics. I have copy-pasted the code bellow.
Going to create an Enum for spell level inshallah. Spell level will be a factor in trsmog and manacost.
enum spelllevel { cantrip=0,minor=1,moderate=2,major=3}
@export var splevel : spelllevel
not sure if this should go here or in what it’s affecting. either way I’ll have to make a signal I guess.
enum trsmog_affinity { none =0,weak=1,moderate=2,strong=3}
@export var trsmogaf : trsmog_affinity
var sp_trsmog = trsmogaf * splevel
var mana = ((splevel * 10) + 10) :
set(value):
mana = clamp(value,0,INF)
@onready var timer: Timer = $Timer
@export var spell = true
func _ready() → void:
timer.start()
print(“spell is cast”)
print(sp_trsmog)
print(splevel)
print(trsmogaf)
print(mana)
The output is :
spell is cast
0
3
3
10
Any help will be appreciated!