 |
Castle Paradox
|
| View previous topic :: View next topic |
| Author |
Message |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Tue Nov 14, 2006 10:47 am Post subject: |
|
|
There's no trace of keyispressed in the script.  |
|
| Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Nov 14, 2006 11:48 am Post subject: |
|
|
TMC's code should do the trick:
| Code: | script, key mash, begin
variable(time) #how long we've been waiting
variable(reps) #how many times the key has been pressed
time := 0
reps := 0
#loop until finished mashing/ran out of time
while(time << TIME_LIMIT, and, reps << KEYPRESSES_NEEDED) do(
if (keyval(KEY) >> 1) then(
reps += 1
)
#add another tick to time passed
time += 1
wait
)
#now we've evaluated the key mashing sequence, act accordingly
if (reps == KEYPRESSES_NEEDED) then(
#do what you want for success
)
else (
#do what you want for failure
)
end |
See 'Plot:Keyval' for info on the keyval function. It should save you some trouble writing the script. _________________
|
|
| Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Tue Nov 14, 2006 1:15 pm Post subject: |
|
|
Sorry, there were a couple of examples posted. I meant my code:
| Code: | script, key mash, begin
variable(time) #how long we've been waiting
variable(reps) #how many times the key has been pressed
time := 0
reps := 0
#check for key mashing for the duration of the time limit
while(time << TIME_LIMIT) do(
if (key is pressed(KEY) == 1) then(
reps := reps +1
)
#if we've key mashed enough, finish the loop early
if (reps == KEYPRESSES_NEEDED) then(
time := TIME_LIMIT
)
#add another tick to time passed
time := time + 1
wait
)
#now we've evaluated the key mashing sequence, act accordingly
if (reps == KEYPRESSES_NEEDED) then(
#do what you want for success
)
else (
#do what you want for failure
)
end |
Of course, TMC's code should work just as well if you don't want to do a search and replace... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|