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

Continuous script checking?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Sun Aug 31, 2003 7:59 am    Post subject: Continuous script checking? Reply with quote

I want a script in my game to be checked constantly, so I'm guessing I use WHILE, and DO statements but i'm not sure how to use them properly. I want my game to continously check this script...

script,my script,begin

if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
then (show text box (270))
wait for text box

end
Back to top
View user's profile Send private message
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Sun Aug 31, 2003 9:02 am    Post subject: Reply with quote

Considering what is going on in the script, you most likely won't have to use a while loop. My guess is that while the player is walking around, you want to check if he's on a specific spot. Particularily, where NPC #2 is.

So, if that's the case, all you have to do is throw that script into the "every step" script that you find in the general settings in each map (You know, it's the same place you set the map's music and stuff).

So, that ought to do it. If you need it to work in some other way, be sure to say it and I'll help you further.
Back to top
View user's profile Send private message
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Sun Aug 31, 2003 10:46 am    Post subject: Reply with quote

oh sorry I should have explained more. I have already tried that and the problem with that is the npcs in this script are moving, and also activated by "step on", so the script would only be called if the npc and hero were running "within" each other (if that makes sense).

I think I will need a while loop, just because both the npc's and the hero are moving.
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: Sun Aug 31, 2003 1:57 pm    Post subject: Reply with quote

Well.. since you need to know how to make for loops anyway:



Code:

while (*condition*) do, begin

if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
then (show text box (270))
wait for text box

end


This will loop while the condition is true. If you want it to loop forever, use (true). However, this will loop FOREVER (well, actually, only only until the player quits and loads their game), and will give you a warning. Otherwise use

while (current map == 4) do, begin

etc
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Mon Sep 01, 2003 12:48 am    Post subject: Reply with quote

ok, here is my script now:

script,my script,begin

while (current map == 5) do, begin)
if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
then (show text box (270))
wait for text box

end

but their is a problem, whenever I load up my game the screen remains blank? My game is saved on map 5, is this a problem or does it have to do with looping? By the way, what I'm trying to do is just make a script run when the npc and hero are on the same tile, normally i'd use "step on", but this doesnt work when both npcs and the hero are moving, if theres any easier way to do this i'd be happy to hear.
Back to top
View user's profile Send private message
djfenix




Joined: 12 Mar 2003
Posts: 359

PostPosted: Mon Sep 01, 2003 12:53 am    Post subject: Reply with quote

You have an extra ")"

script,my script,begin

while (current map == 5) do, begin ) #right here
if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
then (show text box (270))
wait for text box

end
Back to top
View user's profile Send private message
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Mon Sep 01, 2003 10:27 am    Post subject: Reply with quote

I dont think thats the problem, I only added that in after it wouldnt allow me to compile saying "script my script is missing end or )
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 Sep 01, 2003 11:14 am    Post subject: Reply with quote

You forgot the end for the script. Loops Need beginnings and ends just like anythign else. My fault, I confised you by only copying the piece of code in the middle. Heres your script:

Code:


script,my script,begin
 while (current map == 5) do, begin
  if (heroX(me)==NPCX(2), and, heroY(me)==NPCY(2))
  then (show text box (270))
  wait for text box
 end
end


_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Wed Sep 03, 2003 1:48 am    Post subject: Reply with quote

ok thanks everyone, I've got it working for npc 2 now, but there are 7 others I still need to script. I though I'd just do this, but some of the npcs aren't triggering anything at all, where as some are:

script,my script,begin

while (current map == 5) do, begin
if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(3),and,heroY(me)==NPCY(3))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(5),and,heroY(me)==NPCY(5))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(6),and,heroY(me)==NPCY(6))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(7),and,heroY(me)==NPCY(7))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(8),and,heroY(me)==NPCY(8))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(9),and,heroY(me)==NPCY(9))
then (show text box (270))
wait for text box
if (heroX(me)==NPCX(11),and,heroY(me)==NPCY(11))
then (show text box (270))
wait for text box

end
end


is the script the problem or is it something else?
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




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

PostPosted: Wed Sep 03, 2003 2:25 am    Post subject: Reply with quote

Your "wait for text box" commands belong inside the "then" bocks.
You should also have a "wait(1)" at the end of the "while" loop

Code:

script,my script,begin

  while (current map == 5) do, begin

    if (heroX(me)==NPCX(2),and,heroY(me)==NPCY(2))
      then (show text box (270),wait for text box)
   
    if (heroX(me)==NPCX(3),and,heroY(me)==NPCY(3))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(5),and,heroY(me)==NPCY(5))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(6),and,heroY(me)==NPCY(6))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(7),and,heroY(me)==NPCY(7))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(8),and,heroY(me)==NPCY(8))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(9),and,heroY(me)==NPCY(9))
      then (show text box (270),wait for text box)

    if (heroX(me)==NPCX(11),and,heroY(me)==NPCY(11))
      then (show text box (270),wait for text box)

    wait(1)

  end # end of while
end # end of script


Also, this is a perfect candidate for an autonumbered script, so you might want to write the script like this, if it looks cleaner to you (but if it doesn't make it any easier for you to read,then don't bother, because it isn't going to run faster or better or anything):

Code:

define script (autonumber,check NPC collision, 1, 0)

script, check NPC collision, NPC, begin
    if (heroX(me)==NPCX(NPC),and,heroY(me)==NPCY(NPC))
      then (show text box (270),wait for text box)
end

script,my script,begin
  while (current map == 5) do, begin
    check NPC collision(2)
    check NPC collision(3)
    check NPC collision(5)
    check NPC collision(6)
    check NPC collision(7)
    check NPC collision(8)
    check NPC collision(9)
    check NPC collision(11)
    wait(1)
  end # end of while
end # end of script
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bob the Hamster
OHRRPGCE Developer




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

PostPosted: Wed Sep 03, 2003 2:31 am    Post subject: Reply with quote

Another thought. using NPC ID's is pretty slow. If this script runs too slow for you, cache NPC references in local script variables like this:

Code:

define script (autonumber,check NPC collision, 1, 0)

script, check NPC collision, NPC, begin
    if (heroX(me)==NPCX(NPC),and,heroY(me)==NPCY(NPC))
      then (show text box (270),wait for text box)
end

script,my script,begin
  variable(ref2,ref3,ref5,ref6,ref7,ref8,ref9,ref11)
  ref2:=NPC reference(2)
  ref3:=NPC reference(3)
  ref5:=NPC reference(5)
  ref6:=NPC reference(6)
  ref7:=NPC reference(7)
  ref8:=NPC reference(8)
  ref9:=NPC reference(9)
  ref11:=NPC reference(11)
  while (current map == 5) do, begin
    check NPC collision(ref2)
    check NPC collision(ref3)
    check NPC collision(ref5)
    check NPC collision(ref6)
    check NPC collision(ref7)
    check NPC collision(ref8)
    check NPC collision(ref9)
    check NPC collision(ref11)
    wait(1)
  end # end of while
end # end of script


it looks kinda ugly and confusing, but it will be signifigcantly faster, because it only needs to locate the NPC's once, not re-locate them for every single cycle of the "while"
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Wed Sep 03, 2003 3:30 am    Post subject: Reply with quote

Being new to coding, i understand that vaguely... and I used it in my script and I still have the same problem. The script will only run on the first npc you encounter (#2 in this case), so there is one copy of npc 2 that works fine, but as you encounter all the other different npcs nothing is triggered. I dont have any idea what to do so maybe i'll abort this. But if it means anything, text box 270 has a script running next after it. Pissed off! I wish I knew what I was doing, this is probably so simple.
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: Sat Sep 06, 2003 5:19 am    Post subject: Reply with quote

Script triggered? That might be it. Explain what the script does...
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Awful Waffle




Joined: 18 Jun 2003
Posts: 73
Location: Canada

PostPosted: Sat Sep 06, 2003 6:30 am    Post subject: Reply with quote

here is the script following textbox 270, if you can't find a problem don't worry about it, i'm working around this...

script,text270script,begin

suspend player
show text box (271)
wait for text box
fade screen out (63,63,0)
fade screen in
set hero position (me,11,44)
set hero direction (me,up)
wait for hero (me)
show text box (272)
wait for text box
resume player

end
Back to top
View user's profile Send private message
Flamer
The last guy on earth...




Joined: 04 Feb 2003
Posts: 725
Location: New Zealand (newly discovered)

PostPosted: Sun Sep 07, 2003 12:11 pm    Post subject: Reply with quote

Code:
script,text270script,begin

suspend player
show text box (271)
wait for text box
fade screen out (63,63,0)
fade screen in
set hero position (me,11,44)
set hero direction (me,up)
wait for hero (me)
show text box (272)
wait for text box
resume player

end


from what can get from this...
textbox 271 displays
the screen flashes
hero then teleports to (11,14)
and textbox 272 displays.
you don't need the "wait for hero" since the hero isn't wlking, and is instantly transported to (11,14)

what mistakes or better yet, what do you want this to do?

are you sure you want to fade screen in straight after a fade screen out??
wouldn't it be a better idea to have it like this...
Code:
fade screen out (63,63,0)
set hero position (me,11,44)
set hero direction (me,up)
fade screen in

_________________
If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch Raspberry!
(no offense to anyone that was mentioned)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 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