¿ªÔÆÌåÓý

how to keep variables from resetting


 

Ok,

so I am giving a whack at coding the weather tables from Harn.
And the way that it works is that you have a starting number, and then adjust it up or down each day by a small factor. (one or 2 rows on the table, determined randomly).

I am running into the problem of everytime I trigger the table, it is rerolling that random 1-20 number instead of remembering it.

How can I save that initially generated number?

right now, my code looks like this:
----------------------------------------------------
%num%,0
:Start
1,?{if~%num%<=0?|num={Dice~2d10}|}
_{if~%num%>20?|num={Dice~2d10}|}
_[Spring=%num%]
(((((truncated display code)))))
_|adj=[Change]||num+%adj%|
----------------------------------------------------

For example, if? my roll makes number a 14 (after the adjustment at the end), I want the number that is passed in to be 14 the next time I call the table (so long as I have not reloaded the tables.

Any ideas how I can do this?


 

A few thoughts:
- Generate multiple days at one time. You can either have the same table do this or have a "parent" table call another one, preserving the value in the parent and passing it as a parameter to the "child"
- Use a dataset to read/write the number to preserve it
- I had a third suggestion but I can't recall what it is now...





©\©\©\©\©\©\©\ Original Message ©\©\©\©\©\©\©\
On Wednesday, February 10, 2021 6:59 AM, <tim@...> wrote:

Ok,

so I am giving a whack at coding the weather tables from Harn.
And the way that it works is that you have a starting number, and then adjust it up or down each day by a small factor. (one or 2 rows on the table, determined randomly).

I am running into the problem of everytime I trigger the table, it is rerolling that random 1-20 number instead of remembering it.

How can I save that initially generated number?

right now, my code looks like this:
----------------------------------------------------
%num%,0

:Start
1,?{if~%num%<=0?|num={Dice~2d10}|}
_{if~%num%>20?|num={Dice~2d10}|}
_[Spring=%num%]
(((((truncated display code)))))
_|adj=[Change]||num+%adj%|
----------------------------------------------------

For example, if? my roll makes number a 14 (after the adjustment at the end), I want the number that is passed in to be 14 the next time I call the table (so long as I have not reloaded the tables.

Any ideas how I can do this?


 

Yeah, I am playing with datasets now, trying to figure them out