New variable on runtime

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

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

*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.

What’s your specific use case?

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

You have *create_array and *temp_array now:

*create_array myarr 100 "default value"

Does that help?

1 Like