Creating variables as a function of other variables?

I’m having trouble with making variables as a function of other variables. When I try to do this:
‘’‘create health 100+(vigor10)’‘’
I get an error, and I also want to do more complex stuff like:
‘’‘create max_strength 100+(conden25)+(foundation50)+(core75)’‘’

How should I mix my formatting? I saw a similar question on the forum but it was a slightly different idea and I tried to copy its formatting and didn’t work. Any help is greatly appreciated!

1 Like

Use *create to create your variables first, and then *set to change them to the value you want.

If id do that in the startup file will that apply to the rest of the game? Like will one point in vigor automatically increase health by 10?

I don’t fully understand what you’re trying to do, but I think you’re mixing up stuff.
Variable names are one thing, and variable values are another.

Yeah I get that, I want the value of the health variable to increase by 10 every time a point is added to the value of the vigor variable and every time a point is subtracted from the vigor variable. For some reason the text didn’t copy but the function should be
*set health 100+(vigorx10)

where the x stands for times or multiplication

when I huse the star symbole it doesnt copy

Is that like the max health the player can get depending on the vigor it has?

yes!

In startup.txt

*create health 100
*create vigor 10

Then whenever vigor can be increased

*set health (health + vigor)

Is this what you are after?

Yeah! Is there a way to code it so that happens automatically when vigor is increased, or do I need to hard code it every time.

I suppose that the formula should be something like this

*set health 100+(vigor*10)

You can set a separate file to do the math and call it with a goto every time the vigor changes.

Ah, okay that makes sense, thank you!

1 Like

Yes. Create a scene called health and in it put

*set health (health + vigor)
*return

Then when ever you increase vigor you do this.

You drink the vigor potion.
*gosub_scene health
*goto next_scene

That works great! Thank you!

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.