How can I set a variable value from a math equation?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Fafale

‎ ‎ ‎ I want to set a Label’s text to a specific variable’s value and this variable keeps changing throughout the entire game, but it always varies according to a equation.

export var chosen_ability = 'dash'
var dash_status = str(stepify(dash_cooldown/60, 0.0001)) + 'seconds'
var explosion_status = str(stepify(explosion_radius/100, 0.01)) + 'meters'
var ability_status_label = get(chosen_ability + '_status')

func _process(delta):
    $Label.text = ability_status_label

‎ ‎ ‎ The problem is, even if dash_status changes, ability_status_label won’t change (Consequently, the label won’t change either) because it only gets the first calculated value of the equation.
‎‎ ‎ ‎ And I can’t set the value directly because the equation changes according to the selected Ability.

‎ ‎ ‎ So, my question is: Is there any way that I can set ability_status_label to the EQUATION itself, and not the RESULT? With that, I could just set it to a specific equation and have it calculating itself for the rest of the game.

E.g: Instead of changing a variable to 3 (Result), change it to 6/2 (Calculation).

:bust_in_silhouette: Reply From: Calinou

You need to store the original equation as a String alongside the calculated value. If you only store the calculated value, there is no way to go back to the exact original equation – you can only approximate it.