Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Repetitive key-press script?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
TwinHamster
♫ Furious souls, burn eternally! ♫




Joined: 07 Mar 2004
Posts: 1352

PostPosted: Tue Nov 14, 2006 10:47 am    Post subject: Reply with quote

There's no trace of keyispressed in the script. Neutral
Back to top
View user's profile Send private message Send e-mail AIM Address
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Nov 14, 2006 11:48 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Camdog




Joined: 08 Aug 2003
Posts: 606

PostPosted: Tue Nov 14, 2006 1:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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