Hi....
I am really new to this subject of javascript and coding so forgive me if I ask stupid questions.
I am messing around with Leon's Timer Test.tws and learning a lot in the process.
What I want is to do is to change <<start_timer 10>> to a random number between 10 and 30 seconds.
I tried assigning <<set $tm = Math.floor(Math.random()*30+10)>> and passing $tm to <<start_timer $tm>> but I am getting nowhere.
What am I doing wrong or not doing please?
Comments
On to the problem you're having. What you're trying to do isn't working for two reasons.
[list type=decimal]
You are very likely using a vanilla story format (probably Sugarcane). The vanilla story formats' macro processor does not automatically provide support for $variables used as arguments to macros.
The specific macros you're working with (from
Timer Test.tws
) do not natively support the use of $variables as arguments to them.End result: You cannot use $variables directly with the combination of macros you're using and the story format you're using them with.
Possible workarounds:
[list type=decimal]
Use
<<print>>
to pre-reference your $variables.Modify the macros to support $variables as arguments.
#1 would probably be easiest for you to accomplish and could be done like so: (n.b.
random()
has been adopted by the vanilla story formats, so it's not a SugarCube exclusive anymore)Secondly, thank you so much TheMadExile and EcnelOvelam...Your solution has done the trick and works fine.
For the record I am using Sugarcube ver 0.9.9