combine inventory items issues

Started by Fegadrive, Wed 07/07/2010 02:15:10

Previous topic - Next topic

Fegadrive

Hello

im having a bit of a problem coding something and would appreciate if anybody could help me out. I've only just started using AGS so i am a bit of a noob.
My problem is with combining inventory items. my aim is to allow my character to combine, an empty bottle, petrol, and an old cloth to make a petrol bomb. im not sure what im doing wrong but the code isnt working how id like it to and items are appearing and disapearing in the inventory when they are not wanted to. this is an example of the code i am using.

function ifullwine_UseInv()
{
if (cJon.ActiveInventory==iTorncurtain)
cJon.LoseInventory(iTorncurtain);
cJon.LoseInventory(ifullwine);
cJon.AddInventory(iwinebomb);

(cjon. is my character)

Gilbert

You are not putting the blocks of codes in braces correctly.

function ifullwine_UseInv()
{
  if (cJon.ActiveInventory==iTorncurtain) {
    cJon.LoseInventory(iTorncurtain);
    cJon.LoseInventory(ifullwine);
    cJon.AddInventory(iwinebomb);
  }
}

Ryan Timothy B

Hmm.. or it's as simple as Gilbet pointed out.  :P haha



Anyway, you're supposed to have an UseInv action for each inventory item.

Code: ags

function iEmptyWineBottle_UseInv()
{
  if (player.ActiveInventory == iPetrol)
  {
    player.Say("I've added the petrol to the wine bottle.");
    player.LoseInventory(iEmptyWineBottle);
    player.AddInventory(iFullWineBottle);
    player.LoseInventory(iPetrol);
  }
  else if (player.ActiveInventory == iTornCurtain)
  {
    player.Say("I should fill the bottle first.");
  }
}

function iPetrol_UseInv()
{
  if (player.ActiveInventory == iEmptyWineBottle)
  {
    player.Say("I've added the petrol to the wine bottle.");
    player.LoseInventory(iEmptyWineBottle);
    player.LoseInventory(iPetrol);
    player.AddInventory(iFullWineBottle);
  }
}

function iTornCurtain_UseInv()
{
  if (player.ActiveInventory == iEmptyWineBottle)
  {
    player.Say("I should fill the bottle first.");
  }
  else if (player.ActiveInventory == iFullWineBottle)
  {
    player.Say("I've inserted the cloth into the filled wine bottle.");
    player.LoseInventory(iFullWineBottle);
    player.LoseInventory(iTornCurtain);
    player.AddInventory(iWineBomb);
  }
}

function iFullWineBottle_UseInv()
{
  if (player.ActiveInventory == iTornCurtain)
  {
    player.Say("I've inserted the cloth into the filled wine bottle.");
    player.LoseInventory(iFullWineBottle);
    player.LoseInventory(iTornCurtain);
    player.AddInventory(iWineBomb);
  }
}

Mati256

Quote from: Fegadrive on Wed 07/07/2010 02:15:10
my aim is to allow my character to combine, an empty bottle, petrol, and an old cloth to make a petrol bomb.

Me want to play!  :o
My Blog! (En Español)

Fegadrive

yup thats fixed the problem.

thanks Ryan   :)

SMF spam blocked by CleanTalk