Author Topic: If troubles  (Read 827 times)  Share 

Michael Zhu

  • Tactical simulation expert
If troubles
« on: 15 Apr 2003, 12:36 »
I've tried to input a script which has:
if ((character blah inv(10) = 1) && etc etc {
   addinventory(2);
   loseinventory(1); }

into a "interact with hotspot" interaction, the program says something like "script isn't finished, missing }" but I did have the beginning if script { and the end }.
Is it esential to have an Else command after the if one?
Where do I put the If functions in a room?
If man carried away in bodybag, say "KOMATA!" and his soul will go to Bodycount Productions.

Ishmael

  • I put AGS on my CV.
    • I can help with translating
    •  
Re:If troubles
« Reply #1 on: 15 Apr 2003, 12:43 »
if (character blah inv(10) = 1) && etc etc {
  AddInventory(2);
  LoseInventory(1); }

Try this...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
|

Erica McLane

  • AGS user since v2.12
Re:If troubles
« Reply #2 on: 15 Apr 2003, 13:24 »

scotch

  • Mittens Baronet
Re:If troubles
« Reply #3 on: 15 Apr 2003, 14:58 »

Michael Zhu

  • Tactical simulation expert
Re:If troubles
« Reply #4 on: 17 Apr 2003, 07:03 »
I know the script, but where do I put it? In a hotspot? in a room script? Character Enter Screen Before/After Fade in?
If man carried away in bodybag, say "KOMATA!" and his soul will go to Bodycount Productions.

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re:If troubles
« Reply #5 on: 17 Apr 2003, 07:43 »
You must use double "=" for comparison too:

if ((character[blah].inv(10) == 1) && etc etc) {
  AddInventory(2);
  LoseInventory(1);
}

About where to put the script, it just depends on what you want it to do. We can't help you unless you give more info.

Michael Zhu

  • Tactical simulation expert
Re:If troubles
« Reply #6 on: 18 Apr 2003, 06:35 »
The placement isn't a problem anymore.
When I enter:
-----------------------------------------------------
if (player.inv[3] == 1 )  {
   Display("You suck!" //or whatever
}
-----------------------------------------------------
the game works fine, but when I use multiple conditions such as:
---------------------------------
if ((player.inv[3] == 1) && (player.inv[5] == 1) && (player.inv[69] == 1))  {
   Display("Sixty nine. Hehe, dirty mud.");
}
--------------------------------------------------------
AGS says something about not being able to comprehend "Nested functions" or I'm missing a } in the script, which I have checked for {s and }s several times over. Is AGS mongilated or am I doing something wrong?
If man carried away in bodybag, say "KOMATA!" and his soul will go to Bodycount Productions.

scotch

  • Mittens Baronet
Re:If troubles
« Reply #7 on: 18 Apr 2003, 12:09 »
I've had that before.. it was actually because there was a } missing even if it didn't look like it.  Make sure you are looking at the entire room script rather than just the script for an interaction when you check, it's easier to see.

I think the nested funtion error is because you have missed the last } from a function so it thinks you're trying to create a new function inside the last one, which it can't do.