Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: guv on Fri 17/10/2008 10:19:41

Title: useinv problem
Post by: guv on Fri 17/10/2008 10:19:41
what is the scripting to use an object on a char and then after that use another

how can i fit two functions into the "use inventory on" space

Title: Re: useinv problem
Post by: Khris on Fri 17/10/2008 11:37:49
bool done;

function cChar_UseInv() {
  InventoryItem*ai = player.ActiveInventory;
  if (ai == iItem1) {
    ...
    done = true;
  }
  else if (ai == iItem2) {
    if (done) {
      ...
    }
    else player.Say("I can't do that yet.");
  }
  else player.Say("I don't want to give that to him.");
}
Title: Re: useinv problem
Post by: guv on Fri 17/10/2008 11:55:30
ok...so i did it...but now when i use the gold it doesn't dissappear from the inv and she repeats what she said for the suitcase...
heres my script...
function csarah_useinv(){{
  if (player.ActiveInventory == isuitcase)
  cFreddy.Walk(190, 161, eBlock, eWalkableAreas);
  csarah.Say("thanks i guess...heres your money...");
  cFreddy.LoseInventory(isuitcase);
  cFreddy.AddInventory(igold);
}
if (player.ActiveInventory == igold){
csarah.Say("great...we'll eventually change the sign...in the meantime why dont you check out the park...try to find something to sell...");
cFreddy.LoseInventory(igold);
cFreddy.AddInventory(iparkkey);
}}
any idea??
Title: Re: useinv problem
Post by: Khris on Fri 17/10/2008 12:06:08
You have misplaced a few brackets:
function csarah_useinv() {
  if (player.ActiveInventory == isuitcase) {
    cFreddy.Walk(190, 161, eBlock, eWalkableAreas);
    csarah.Say("thanks i guess...heres your money...");
    cFreddy.LoseInventory(isuitcase);
    cFreddy.AddInventory(igold);
  }
  if (player.ActiveInventory == igold) {
    csarah.Say("great...we'll eventually change the sign...in the meantime why dont you check out the park...try to find something to sell...");
    cFreddy.LoseInventory(igold);
    cFreddy.AddInventory(iparkkey);
  }
}
Title: Re: useinv problem
Post by: guv on Fri 17/10/2008 13:15:12
thanx again:)