Creating a variable based on another

Hi folks, I have been searching the wiki and the introduction, but did Not found, what I was looking for.

I want to create a variable called maxLife, based on the condition variable. It should be twice as high, as the constitution variable is and Change whenever the con variable Changes.

So normally it should Look like:
create max_life 2von
But that, even with () ends in value must be a number, boolean or String

I know I could set it afterwards, but then it would not automatically change whenever the con changes. Is there an easy solution?

Not entirely certain variables can be created like that to change automatically. i think you need a routine each time CON can change.

8 Likes

Yes. To make sure you don’t forget in some places, you’ll want to make updating con a subroutine.

*gosub Set_Con (con + 5)

And then somewhere at the bottom of your code:

*label Set_Con

*params new_value

*set con new_value
*set max_life (2 * con)

*return
3 Likes

Thank you.

@MeltingPenguins thanks to you, too
I guess I will change Things accordingly.

My question has been answered, could some Mod, please Close this thread

2 Likes