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

Need help with a for loop/while loop

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






PostPosted: Wed Feb 11, 2004 9:15 am    Post subject: Need help with a for loop/while loop Reply with quote

Here's the deal. I made this script that works. If you press the left key, an NPC walks left, right key, the NPC walks right, but I had it set as when key is pressed script.

NOW I am trying to implement it into a forever loop so I can have other things happen (like your guy animate while not walking and such). But when I put on the while loop like so:

while (play==true) do (# this is the NPC walking stuff, which works #)

It doesn't lett me push the keys and make the NPC walk. Why does this happen?

Is there a way I can make a forever loop that'll allow the player to still push keys and such?

I tried doing a for loop like this:

for (play,10,0,0) do(# NPC stuff)

But it still didn't work, same problem. Why?

please help because it is really annoying!!!!!! Pissed off!
Back to top
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Wed Feb 11, 2004 11:44 am    Post subject: Reply with quote

For loops aren't exactly what you'd want to use for something like this, so I'll just do the while loop Raspberry!. So, here's how it ought to work:

Code:
while(play==true) do (
  wait for npc (#)
  if (key is pressed(key:right) then (
    walk npc (#, right, 5)
  )
  if (key is pressed(key:left) then (
    walk npc (#, left, 5)
  )
  wait(1)
)


This may or may not be similar to what you have made yourself, but there's a good chance you just left out the wait(1). You need that or the OHR loops too fast and just well... Stops.

So try that, and see how it goes. Post again if you get any trouble with this script or any others Wink.
Back to top
View user's profile Send private message
T-Master




Joined: 10 Dec 2003
Posts: 74

PostPosted: Wed Feb 11, 2004 1:55 pm    Post subject: Reply with quote

You might want to include a break condition in that.
Back to top
View user's profile Send private message
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Wed Feb 11, 2004 4:07 pm    Post subject: Reply with quote

Oh, well yeah. Of course, the break doesn't nessisarily need to be in the loop itself of course... Just somewhere... Anywhere. Considering he did the condition for the loop argument correctly I'd have to assume he knew that already Raspberry!.
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: Wed Feb 11, 2004 10:40 pm    Post subject: Reply with quote

If you wrote

for (play,10,0,0) do(# NPC stuff)

in your script, when it is run the HS interpreter will simply skip over it, so that won't work.

Yes, you see, the reason you need a wait command is that every time game.exe comes across a wait command, it takes a break from running scripts and does everything else, for example checking what keys are pressed, moving npcs and updating. Without it, game will smply run your while loop for ever, and will never ever refresh the screen.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
a person
Guest






PostPosted: Thu Feb 12, 2004 7:29 am    Post subject: thanks! Reply with quote

Yeah, thanks, I couldn't quite understand it. I thought that the plotscipt, when it came to a "if key is pressed" command it would the check to see if it is pressed at that time. Thanks alot. Razz
Back to top
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