# Creating a variable based on another

**URL:** <https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152>\
**Category:** ChoiceScript Help\
**Tags:** coder\
**Created:** [April 11, 2021, 11:18am UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152 "2021-04-11T11:18:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaelyn](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/kaelyn/32/141616_2.png) [@Kaelyn](https://forum.choiceofgames.com/u/Kaelyn)\
**Post date:** [April 11, 2021, 11:18am UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152/1 "2021-04-11T11:18:06Z")

</div>

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 2_von  
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?

---

<div class="post-metadata">

**Author:** ![MeltingPenguins](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/meltingpenguins/32/255855_2.png) [@MeltingPenguins](https://forum.choiceofgames.com/u/MeltingPenguins)\
**Post date:** [April 11, 2021, 11:35am UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152/2 "2021-04-11T11:35:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris\_Conley](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/chris_conley/32/199055_2.png) [@Chris\_Conley](https://forum.choiceofgames.com/u/Chris_Conley)\
**Post date:** [April 11, 2021, 6:02pm UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152/3 "2021-04-11T18:02:00Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![Kaelyn](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/kaelyn/32/141616_2.png) [@Kaelyn](https://forum.choiceofgames.com/u/Kaelyn)\
**Post date:** [April 11, 2021, 6:06pm UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152/4 "2021-04-11T18:06:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Szaal](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/szaal/32/112202_2.png) [@Szaal](https://forum.choiceofgames.com/u/Szaal)\
**Post date:** [April 11, 2021, 10:25pm UTC](https://forum.choiceofgames.com/t/creating-a-variable-based-on-another/98152/5 "2021-04-11T22:25:46Z")

</div>

Closed on April 11, 2021, 10:25pm UTC


