Author Topic: how to make a variable variable  (Read 3695 times)

D.D.Harriman

  • Guest
how to make a variable variable
« on: June 04, 2017, 08:39:27 AM »
In the script in tis thread >> http://voiceattack.com/smf/index.php?topic=1213.0 << I made a variable time delay. But, now that I have watched it in action a number of times I see that what happens is that when I run the script, it sets a time delay between .2 and .4 seconds and then uses that number every time the delay is called.

How would I actually get a different random delay every time??
One obvious solution is to create multiple decimal values and call a different one for each pause. But that just looks overly complex.

There must be a simpler way. 

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: how to make a variable variable
« Reply #1 on: June 04, 2017, 10:29:22 AM »
You have to regenerate the variable's value before use, as they're designed to retain the last value you put into it.

You can reduce your command(provided it's the one you posted before) to this:
Code: [Select]
Press down NumPad Add key
Start Loop : Repeat 13 Times
Press down NumPad 7 key
Set decimal [Dance Time] value as random from 0,4 to 0,8
Pause a variable number of seconds [dance time]
Release NumPad 7 key
Press down NumPad 1 key
Set decimal [Dance Time] value as random from 0,4 to 0,8
Pause a variable number of seconds [Dance Time]
Release NumPad 1 key
Pause 1,5 seconds
End Loop
Release NumPad Add key

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: how to make a variable variable
« Reply #2 on: June 04, 2017, 12:09:52 PM »
Good example, Pfeil.  This looks like a job for a new token as well.  {RANDOMDEC} will work like, {RANDOM} except that it will produce a decimal-based random value (versus integer).  Also dropping the, 'no token' restriction on the variable pause screen, as there really isn't that much overhead to check whether or not a token is being used.
« Last Edit: June 04, 2017, 12:21:19 PM by Gary »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: how to make a variable variable
« Reply #3 on: June 04, 2017, 01:56:40 PM »
New beta is out there now ;)

D.D.Harriman

  • Guest
Re: how to make a variable variable
« Reply #4 on: June 04, 2017, 02:21:55 PM »
Ok Pfeil.
If there is some way I can bump you up in standing, I will do it.

That is FAR more elegant than the only solution I was seeing.