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

stopping regular control?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
binoal




Joined: 20 Jun 2009
Posts: 123
Location: My Own Little World

PostPosted: Wed Aug 26, 2009 1:34 pm    Post subject: stopping regular control? Reply with quote

is there any way to stop the arrow keys from making you walk? i made a script that makes you look in the direction you press and then if you hold it you walk in that direction. but it isnt working because the arrow keys are still making you move so its getting you off the grid and ignoring walls and just generally bugging up
_________________
Resident Evil RPG Demo

http://www.castleparadox.com/gamelist-display.php?game=963

Legend Of Zelda: Reptilian Warlord Demo

http://www.castleparadox.com/gamelist-display.php?game=961
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Aug 26, 2009 1:54 pm    Post subject: Re: stopping regular control? Reply with quote

binoal wrote:
is there any way to stop the arrow keys from making you walk? i made a script that makes you look in the direction you press and then if you hold it you walk in that direction. but it isnt working because the arrow keys are still making you move so its getting you off the grid and ignoring walls and just generally bugging up


At the beginning of the script, use suspend player and when the script is finished, use resume player
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binoal




Joined: 20 Jun 2009
Posts: 123
Location: My Own Little World

PostPosted: Wed Aug 26, 2009 4:46 pm    Post subject: Reply with quote

oh i didnt think that would work. i figured since the script is triggered when u press an arrow, it would be moving you before suspend player was activated
_________________
Resident Evil RPG Demo

http://www.castleparadox.com/gamelist-display.php?game=963

Legend Of Zelda: Reptilian Warlord Demo

http://www.castleparadox.com/gamelist-display.php?game=961
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Aug 27, 2009 7:42 am    Post subject: Reply with quote

The secret is that scripts happen before anything else. Unfortunately this also means that you won't find out about what happened (NPCs and heroes starting a new move, textbox appearing, etc) until the player has already seen it.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Thu Aug 27, 2009 8:28 am    Post subject: Reply with quote

Okay, this got me curious, so tried to do it myself, and I came up with these two scripts:

Code:

include, plotscr.hsd
include, scancode.hsi

define constant(0, look timer)

plotscript, on key, begin
  show value(seconds of play)
  variable(looking)
  looking := false
  if (keyval(key:Z) >> 0) then(
    # Look without walking if Z is held down
    stop timer(look timer)
    if(keyval(key:UP)    >> 1) then(set hero direction(me, up),    looking := true)
    if(keyval(key:RIGHT) >> 1) then(set hero direction(me, right), looking := true)
    if(keyval(key:DOWN)  >> 1) then(set hero direction(me, down),  looking := true)
    if(keyval(key:LEFT)  >> 1) then(set hero direction(me, left),  looking := true)
    if(looking) then(
      suspend player
    )
    set timer(look timer, 1, 1, @finish look)
  )
end

script, finish look, begin
  resume player
end


It would indeed be nice if there was an easy way to cancel a keypress. it would make this sort of script much simpler.

We already have a clearkey() function in allmodex.bas. I suppose if we exposed that to plotscripting, then the script could be written like this:

Code:

include, plotscr.hsd
include, scancode.hsi

plotscript, on key, begin
  if (keyval(key:Z) >> 0) then(
    # Look without walking if Z is held down
    if(keyval(key:UP)    >> 1) then(set hero direction(me, up),    cancel key(key:UP))
    if(keyval(key:RIGHT) >> 1) then(set hero direction(me, right), cancel key(key:RIGHT))
    if(keyval(key:DOWN)  >> 1) then(set hero direction(me, down),  cancel key(key:DOWN))
    if(keyval(key:LEFT)  >> 1) then(set hero direction(me, left),  cancel key(key:LEFT))
  )
end


So much simpler!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binoal




Joined: 20 Jun 2009
Posts: 123
Location: My Own Little World

PostPosted: Thu Aug 27, 2009 12:26 pm    Post subject: Reply with quote

i got it to work by doing

Code:

while (key is pressed(57))
do (suspend player
   while (key is pressed(57))
   do (
   if (key is pressed (72))
   then (set hero direction(0,up))
   if (key is pressed (75))
   then (set hero direction(0,left))
   if (key is pressed (77))
   then (set hero direction(0,right))
   if (key is pressed (80))
   then (set hero direction(0,down))
   wait (1))
wait (1)
resume player
)


basically if you are holding space, it sets your direction instead of walking. I had to use 2 seperate While/Do statements so that resume player didnt happen while it was repeating. But this seems to work. My only concern is that it doesnt allow any of the other on keypress scripts to run while you are holding space
_________________
Resident Evil RPG Demo

http://www.castleparadox.com/gamelist-display.php?game=963

Legend Of Zelda: Reptilian Warlord Demo

http://www.castleparadox.com/gamelist-display.php?game=961
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Aug 28, 2009 12:01 pm    Post subject: Reply with quote

Quote:
We already have a clearkey() function in allmodex.bas. I suppose if we exposed that to plotscripting, then the script could be written like this:

The key handling code has been rewritten a couple times in the last year or two, and I can no longer remember whether clearkey has been fixed, but I don't fully trust it and avoid using it. Anyway, I think that this is a feature we should have, but maybe we should provide it in a different way: by letting people suspend and resume keys? Hmm, maybe we'd want clearkey anyway for convenience.

I can't see a reason why it wouldn't work with one of the while loops deleted.

What do you mean by "the other on keypress scripts"? Are they bits of code inside the same keypress handlig scripts? Do they contain their own weights? Is "permit double-triggering of scripts" enabled? It would be possible to let them continue to work while space is being held down.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Fri Aug 28, 2009 1:25 pm    Post subject: Reply with quote

The Mad Cacti wrote:
Quote:
We already have a clearkey() function in allmodex.bas. I suppose if we exposed that to plotscripting, then the script could be written like this:

The key handling code has been rewritten a couple times in the last year or two, and I can no longer remember whether clearkey has been fixed, but I don't fully trust it and avoid using it. Anyway, I think that this is a feature we should have, but maybe we should provide it in a different way: by letting people suspend and resume keys? Hmm, maybe we'd want clearkey anyway for convenience.


I did a test of this. Actually I had to call it "suppress key" to avoid collision with the existing "clear key" constant for the "wait for key" command.

It did not work properly at all. I am guessing you are correct that clearkey() in allmodex.bas has bitrotted. it is only actually used in a very small number of places.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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