# New variable on runtime

**URL:** <https://forum.choiceofgames.com/t/new-variable-on-runtime/140526>\
**Category:** Game Development\
**Created:** [August 3, 2023, 4:00am UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526 "2023-08-03T04:00:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valda\_Reehux](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/valda_reehux/32/126891_2.png) [@Valda\_Reehux](https://forum.choiceofgames.com/u/Valda_Reehux)\
**Post date:** [August 3, 2023, 4:00am UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526/1 "2023-08-03T04:00:29Z")

</div>

Hello awesome people,

is it possible to create new create / temp on runtime?  
I think it would be awesome instead of declaring everything before running the code, but my smol brain couldn’t find a way to do it, a code example would be a great help

thank you

---

<div class="post-metadata">

**Author:** ![Elriwana](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/elriwana/32/215293_2.png) [@Elriwana](https://forum.choiceofgames.com/u/Elriwana)\
**Post date:** [August 3, 2023, 6:46am UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526/2 "2023-08-03T06:46:29Z")

</div>

it’s not directly possible to create new variables or temporary variables during runtime. The language is designed to be static, where all variables and options need to be declared before the code is run.

However, there are ways to simulate dynamic behavior and store temporary values. One common approach is to use the `*temp` command to create temporary variables at the start of your code, even if you don’t know the exact values they’ll hold at that point. You can update these variables as the story progresses. For example

```plaintext
*temp health 100
*temp strength 10

You have ${health} health and ${strength} strength.

*set health 90
*set strength 15

Now you have ${health} health and ${strength} strength.

```

If you need more dynamic functionality, you could use different combinations of existing variables to simulate dynamic behavior.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [August 3, 2023, 3:26pm UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526/3 "2023-08-03T15:26:11Z")

</div>

What’s your specific use case?

---

<div class="post-metadata">

**Author:** ![Valda\_Reehux](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/valda_reehux/32/126891_2.png) [@Valda\_Reehux](https://forum.choiceofgames.com/u/Valda_Reehux)\
**Post date:** [August 4, 2023, 2:44am UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526/4 "2023-08-04T02:44:27Z")

</div>

well, no specific uses as for now

I’m just tired to declare lots of arrays, let’s say there is a tennis tournament with 100 registered athletes  
instead of creating “rank\_1, rank\_2, up to rank\_100” to store athlete’ name and “point\_1, point\_2, up to point\_100” to store their points accumulated during tournament, I’d hope we can use dynamic create or temp:

\*set i 1  
\*set j 100  
\*loop from i to j  
\*create “rank\_”&i

or something like that, but when I tried yesterday it gives me an error saying that: \*create/\*temp has to start with a letter

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [August 4, 2023, 6:48pm UTC](https://forum.choiceofgames.com/t/new-variable-on-runtime/140526/5 "2023-08-04T18:48:31Z")

</div>

You have \*create\_array and \*temp\_array now:

```plaintext
*create_array myarr 100 "default value"
${myarr[1]}
...
${myarr[100]}

```

Does that help?
