Character Replies to Inventory Item

Started by , Wed 25/10/2006 18:48:57

Previous topic - Next topic

SisteenStone

I have a part where my main character wants to buy a bandana from another character. But he shouldn't be able to if he already has it. So under intaractiond for the selling character I have:

Use Inventory item on character
--Conditional - If the player has an inventory object
----Run Script: Character[Engel].Say("You already have the Bandana!")

But I get an error : Variable [ is already defined

What am I doing wrong?

Thanks!!!

Candall

I'm not sure where it's getting the singular opening brace.  I can only guess that it's from someplace before in your script.

As for that code, you should change Character[Engel] to cEngel, so that it now says:

cEngel.Say("You already have the bandana!");

Perhaps AGS thinks you have a variable called "[" because you mistakenly used that type of notation (which is used for arrays, not class instances) beforehand.

SisteenStone


Candall


strazer

I think it was due to capitalization. AGS is case-sensitive, so it should have been
  character[ENGEL].Say("You already have the Bandana!");
(Also note the semi-colon at the end in case it wasn't in your script.)

But cEngel is easier, obviously.

SisteenStone

Okay so I have gotten all that working now, but there are a couple of more problems I've encountered.

First:
I want to include the speech sound(Enge627.wav) for when he says "You already have the bandana!" So i tried the following:

PlaySoundEx (627, 3)

But it doesn't seem to work!

Secondly,

I have the following under 'Use inventory of character'

--Conditional - if the player has an inventory item (3) <---The Bandana
-----Run script: cEngel.Say("You already have the bandana!");
                        AmountOfMoney += 2;

--Conditional - if inventory item was used (2) <---- The Cash
-----Player - Give Player the inventory item
-----Run Script: AmountOfMoney -= 2; 
                        cEngel.Say("Here you go, Enjoy the bandana!");


So if the player tried to buy it again Engel gives the money back do you don't spend any more. That works, but after Engel says "You already have the bandana" he says "Here you go enjoy the bandana!" Any reasons for this?

Thanks again!

Gilbert

PlaySound[Ex](), works wit files named like sound627.wav only.
If you like to follow the convenient speech sound naming format, you only need to do it like:

cEngel.Say("&627 You already have the bandana!");

SisteenStone

Wow, I have been doing that all along but I tried it before and it didn't work, but now it does... THANKS! ;D

Also, is there a way, under interactions, to make a Conditional -Ã,  If the player has an inventory item (3) = false... meaning only if the player DOESN'T have the inventory item will the event occur???

Gilbert

If you're using the interaction editor, you may try doing this (note the indenting):

Conditional - if the player has an inventory item (3)
Ã,  Ã, Stop running more commands
(do whatever you want here)

Khris

As you are already using RunScript-actions, why not switch completely?

The code would look like this:
if (player.ActiveInventory=iCash) {
  if (player.InventoryQuantity[iBandana.ID]>0) {
    cEngel.Say("You already have the bandana!");
  }
  else {
    player.AddInventory(iBandana);
    AmountOfMoney -= 2; 
    cEngel.Say("Here you go, Enjoy the bandana!");
  }
}
else {
  cEngel.Say("I have no use for this.");
}

Gilbert

Because it's still easy to make errors at first, and even for experienced users.
if (player.ActiveInventory==iCash) {
Ã,  if (player.InventoryQuantity[iBandana.ID]>0) {
Ã,  Ã,  cEngel.Say("You already have the bandana!");
Ã,  }
Ã,  else {
Ã,  Ã,  player.AddInventory(iBandana);
Ã,  Ã,  AmountOfMoney -= 2; 
Ã,  Ã,  cEngel.Say("Here you go, Enjoy the bandana!");
Ã,  }
}
else {
Ã,  cEngel.Say("I have no use for this.");
}



Just kidding of course! ;D

SMF spam blocked by CleanTalk