At the bottom of the page I have a block I tried to make. It’s supposed to function like a wait until block, but it shouldn’t go past a certain time (ex: wait until (space key pressed) but only up to 5 seconds). I took the script out and adjusted it, and it works fine. But when I put it in the block, it ignores the key space pressed prompt.
That's because your block waits for the ring, but not the value of it, so it always returns true and it doesn't wait. This can be fixed with a simple (call) block on ...until <<...> or (call (cond))>
Last version
I've done a total rewrite of your block:
{wait ((duration = 1)) seconds or until ((pred λ)):: control}:: define+
script variable ((time started))@<>
set [time started V] to (current [time in milliseconds V])
wait until <<((current [time in milliseconds V]) - (time started)) \> ((duration) × (1000))> or (call (pred) @:>)@<:> >If this doesn't work, let me know.
You can adjust this a tiny bit by changing the
<<> > <>>
block to
<<> ≥ <>>
Yeah, yeah, it is just a 1 millisecond difference, but every millisecond counts!
To OP :
If you need a script pic of tethrarxitet's script, here it is:
(I made minor tweaks to it)
Can you explain the tweaks and what they do? Also thanks for the help!
I used the Greater than or Equal to block instead of the generic Greater than block so then it stops ever so slightly earlier. Also I used block variable instead of script variables (which are basically the same thing) to use one less block.
Thanks!
If you don't know how to get them, right click a <<> > <> @<:> > block, and select relable, and thwn you'll see an option for <<> \>= <> @<:> >
Actually, they are not. Here is some information about block variables:
Here’s an example:
Here’s some more clarification. Every time you call this exact block, it will report the same random number:
However, a separate physical block will result in separate random numbers:
In the case of your block, nothing will seem to be amiss until you use the same instance of the block multiple times simultaneously. For example, the script below will never cause the sprite to move because “time started” keeps being reset by other threads (processes) running the same instance of that block.
Does that clear things up for you?
PS: That was a perfectly understandable mistake to make, and one that I made too before reading the manual.
Huh, I didn't know that. Thanks!
So basically is is a script variable, except when you run the block again the value doesn't reset (unless you tell it to)?
Pretty much, yeah.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.



