Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Chicky on Fri 11/06/2004 21:31:38

Title: Need help with if statement
Post by: Chicky on Fri 11/06/2004 21:31:38
hey I'm having some trouble with this:

// room script file

#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a() {
  // script for hotspot1: Any click on hotspot, bullet counter
//12
If (GetObjectGraphic(0)==6)
    { SetObjectGraphic(0,7)}
   
//11
   
If (GetObjectGraphic(0)==7)
    { SetObjectGraphic(0,8)}
//10

If (GetObjectGraphic(0)==8)
    { SetObjectGraphic(0,9)}
//9   

If (GetObjectGraphic(0)==9)
    { SetObjectGraphic(0,10)}
   
//8
If (GetObjectGraphic(0)==10)
    { SetObjectGraphic(0,11)}
//7

If (GetObjectGraphic(0)==11)
    { SetObjectGraphic(0,12)}
   
//6
If (GetObjectGraphic(0)==12)
    { SetObjectGraphic(0,13)}
   
    //5
   
   
If (GetObjectGraphic(0)==13)
    { SetObjectGraphic(0,14)}
   
    //4
   
If (GetObjectGraphic(0)==15)
    { SetObjectGraphic(0,16)}
   
    //3
   
If (GetObjectGraphic(0)==16)
    { SetObjectGraphic(0,17)}
   
    //2
   
If (GetObjectGraphic(0)==17)
    { SetObjectGraphic(0,18)}
   
    //1
   
If (GetObjectGraphic(0)==18)
    { SetObjectGraphic(0,19)}
   
    //reload
   
If (GetObjectGraphic(0)==19)
    { SetObjectGraphic(0,20)}
}
#sectionend hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for room: First time player enters screen
SetObjectGraphic (0,6) ; 
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


Basicly its seeing wether a object is set at a certain image and if it is then its setting it to another.

Sorry if this is pretty simple, I'm knida new to the scripting side of things.
Title: Re: Need help with if statement
Post by: strazer on Fri 11/06/2004 21:49:06
If (GetObjectGraphic(0)==6)
    { SetObjectGraphic(0,7);} // you set pic to 7 here
else
If (GetObjectGraphic(0)==7) // this would be true if you didn't use "else" since you just set it to 7
    { SetObjectGraphic(0,8);} // set pic to 8...
else
...
etc. etc.

Add for all steps.

Does this help?

Edit:

Slightly shorter version of your script:

if (GetObjectGraphic(0) < 20) SetObjectGraphic(0, GetObjectGraphic(0)+1);

;)
Title: Re: Need help with if statement
Post by: Chicky on Fri 11/06/2004 21:59:54
hehe, thanks Strazer. I tried your *slightly* smaller script hehe, and it worked fine.

Thanks again :)
Title: Re: Need help with if statement
Post by: strazer on Fri 11/06/2004 22:15:05
Glad I could help. :)
Title: Re: Need help with if statement
Post by: Mr Flibble on Sat 12/06/2004 19:36:02
Can I suggest the starter of the thread puts a thumbs up beside it?
It would do it myself but I don't know if there are any more probs.
Title: Re: Need help with if statement
Post by: TerranRich on Sat 12/06/2004 22:28:31
The moderators will do this. Mainly, me. Let me do my job!!!!! :P

QuoteI would do it myself...
And how would you go about doing that, O Non-Moderator? :P
Title: Re: Need help with if statement
Post by: Edwin Xie on Mon 14/06/2004 01:09:46
Quote from: Moebius 5.18 on Sat 12/06/2004 22:28:31
The moderators will do this. Mainly, me. Let me do my job!!!!! :P

QuoteI would do it myself...
And how would you go about doing that, O Non-Moderator? :P

That makes me think that he is a person acting like a moderator. And, uhh I think that you want to do everything for yourself. It seems like you like your job.
Title: Re: Need help with if statement
Post by: TerranRich on Mon 14/06/2004 23:17:48
Of course! I love it! :)