if statement - problem ( operator expected )

Started by bloodymirj, Tue 30/12/2008 17:59:42

Previous topic - Next topic

bloodymirj

I am noob with script, so if someone know answer help.
I have 6 hotspots for 6 objects . Every hotspot works like a button, and change object graphic.
(Example-   if player interact hotspot1 then the object1 change graphic to A, next time to B, next time C,then A again...).

   My problem.  I want to meke hotspot 7  to work like some final button which will do function only if there is a right combination of object graphic).   
   I tried this :

function hHotspot23_Interact()
{
   if (oABCprvo.Graphic == 105)
      (oABCtrece.Graphic == 107)
      (oABCtrece.Graphic == 106)
      (oABCcetvrto.Graphic == 107)
      (o123prvo.Graphic == 103)
      (o123drugo.Graphic == 102)
      (o123trece.Graphic == 104)
      (o123cetvrto.Graphic == 103)
          { oSemaforradi.Visible = true ;}


    and this(with variable, where variable  match  right graphics):

function hHotspot23_Interact()
{
   if {oABCprvo.Graphic = 105;}
      (abc2  == 1)
      (abc3  == 3)
      (abc4  == 2)
      (prvo  == 2)
      (drugo  == 3)
      (trece  == 2)
      (cetvrto == 3)
          { oSemaforradi.Visible = true ;}



Akatosh

This should do the trick:

Code: ags

function hHotspot23_Interact()
{
   if ((oABCprvo.Graphic == 105) &&
      (oABCtrece.Graphic == 107) &&
      (oABCtrece.Graphic == 106) &&
      (oABCcetvrto.Graphic == 107) &&
      (o123prvo.Graphic == 103) &&
      (o123drugo.Graphic == 102) &&
      (o123trece.Graphic == 104)  &&
      (o123cetvrto.Graphic == 103))
oSemaforradi.Visible = true;
}  


Remember, if you want to check multiple things in one if-statement, you have to chain them together via either && ("and") or || ("or").

bloodymirj

 Thanks for quick  reply and tip about && and ||.
Game works (have no bugs) but function do nothing. I tried some other functions and same thing happen when i interact with hotspot(nothing:) ) .  Thanks anyway i will try to figure something up.


Trent R

Well, if your function isn't doing anything, it means that it doesn't fulfill all 8 of your requirements. You can check the by putting in an else statement with a Display() call.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Pumaman

Code: ags
      (oABCtrece.Graphic == 107) &&
      (oABCtrece.Graphic == 106) &&


Considering that you're asking for oABCtrece to have two different images at the same time, this will never happen. Or did you want them all to be OR (||) instead of AND (&&)?

Trent R

Quote from: Pumaman on Tue 30/12/2008 23:13:09
Code: ags
      (oABCtrece.Graphic == 107) &&
      (oABCtrece.Graphic == 106) &&

I'm guessing there's supposed to be a oABCdrugo in place of one of those.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

bloodymirj

  Yes, it was typing problem in that. Works now.
  Insted 
           (oABCtrece.Graphic == 107) &&
           (oABCtrece.Graphic == 106) &&
   It should be :
Code: ags
    (oABCdrugo.Graphic == 106) &&
              (oABCtrece.Graphic == 106) &&


  Thank you all guys for help. The forum is great.


Trent R

Quote from: bloodymirj on Wed 31/12/2008 08:17:51
  Thank you all guys for help. The forum is great.
Of course they are! And we're glad to have you here. Welcome to AGS.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Dualnames

Quote from: Trent R on Wed 31/12/2008 17:25:00
Quote from: bloodymirj on Wed 31/12/2008 08:17:51
  Thank you all guys for help. The forum is great.
Of course they are! And we're glad to have you here. Welcome to AGS.


~Trent

Good to know people really like some of us..That's where I come in..and destroy all happiness..and wtf am I typing?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk