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

keypress issues

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 09, 2009 8:55 am    Post subject: keypress issues Reply with quote

I have a "swap party" script that is triggered by keypress.

It's strange: if you lean on the designated key (c), "swap" gets triggered multiple times (before the first finishes execution) even though the "permit multiple script triggers" bit is set to OFF.

I've tried implementing a makeshift "suspend keypress" by only allowing scripts to run when a certain TAG (51) is turned on.
This doesn't seem to work - I can't imagine why.

My keypress script looks sort of like this:
Code:

if (key is pressed(46) ,and, check tag(51)) then(  #c
  set tag (51,off)
  swap # another script
)
set tag (51,on)


Am I doing something wrong?
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Nov 09, 2009 12:24 pm    Post subject: Reply with quote

When a script is triggered, such as an on-keypress, the interpreter checks whether the current script (which, because script are only triggered outside of the interpreter, will always be in the middle of either a wait or one of those very rare commands that cause an invisible wait) is the same as the one that wants to be triggered. If so, "permit multiple script triggers" dictates what will happen. In your case, the current script is swap, and the triggered script is your on-keypress, so the interpreter doesn't see the problem and they pile up.

What you are doing is basically the correct way to prevent double triggering of scripts. However, you should move set tag (51,on) inside the if, otherwise any other keypress will reset the tag! I'm guessing this is your problem, because everything else is right.

You know... you can write key:c instead of 46. I know, I'll remove the table of scancodes from the plotdictionary.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Nepenthe




Joined: 27 Sep 2004
Posts: 132

PostPosted: Mon Nov 09, 2009 12:31 pm    Post subject: Reply with quote

EDIT: TMC beat me to it (and provided a better answer!)

I think you want to check that tag by itself before you do any keyispressed stuff. This is roughly what my keypress script looks like:

Code:
plotscript, keypress, begin
  if(keypressisrunning==false) then( #checks to makes sure a global variable is off
    keypressisrunning:=true #sets the global on
    if(keyispressed(key:w)) then(#do stuff)
    if(keyispressed(key:a)) then(#do other stuff)
    if(keyispressed(key:s)) then(#etc)
    if(keyispressed(key:d)) then(#etc)
    keypressisrunning:=false) #sets the global off again
end


NOTE: I am using the global variable "keypressisrunning" because I have an inexplicable aversion to tags, but I don't see a reason why a tag wouldn't work.
_________________
My art (and random photos)!
Back to top
View user's profile Send private message Visit poster's website AIM Address
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 09, 2009 5:43 pm    Post subject: Reply with quote

Yes, moving the "resume swap" worked - thanks!

One last question: neither typing "key:c" or "c" works for me.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Pepsi Ranger
Reality TV Host




Joined: 05 Feb 2003
Posts: 493
Location: South Florida

PostPosted: Mon Nov 09, 2009 7:20 pm    Post subject: Reply with quote

Quote:
One last question: neither typing "key:c" or "c" works for me.


I believe you have to include scancode.hsi at the top of your plotscript file first. They're not actually included by default.
_________________
Progress Report:

The Adventures of Powerstick Man: Extended Edition

Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.

Tightfloss Maiden

Currently Updating: Chapter 2
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 09, 2009 7:26 pm    Post subject: Reply with quote

Bingo!
_________________
Working on rain and cloud formation
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
Page 1 of 1

 
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