This could easily be a programming skill issue, but I'm clueless as to what I'm doing wrong. I want to do a simple "while the crank is being turned, shake the screen and play a funny noise", as a fun little thing, and the code I came up for it was this:
on crank do
while event.ra!=0 do
shake 0.05
sound "beep"
end
end
Of course it's not perfect, but it seems good enough. However, in practice, the result is touching the crank in any way results in the simulator webpage becoming unresponsive. Needless to say, this was not my intention. Am I doing something wrong? I tried to look for an "advance frame" function or something like it, thinking maybe the issue was it continuously shaking forever on the same frame, though I couldn't find this function. I tried adding a...
wait 0.05 then
end
...as an "advance frame"-like thing, but it didn't seem to do anything. Furthermore, I also tried
on draw do
if event.ra!=0 then
while event.ra!=0 do
//shake & sound things again
end
end
end
yet again, to no avail.
A few things to note; It also crashes even when it is told to do absolutely nothing, so I find it hard to believe the shaking is making it crash, and also if the "while" condition is NOT fulfilled initially, it does NOT crash, so it's not an immediate crash upon using the "while" command as I suspected.
I was tempted to report it as a Pulp bug, but I find it more believable that I'm just not good at programming yet. Is it a Pulp bug or do I need to get good?
Edit: I have also tried this with conditions other than event.ra!=0. Provided the answer is "true", they always crash, without exception.