(SOLVED) Change a inventory object to another by looking at it? (again)

Started by BlueAngel, Sun 22/11/2009 12:41:51

Previous topic - Next topic

BlueAngel

Hi all!
I just stared using the AGS (3.1) and am making my first little game to understand it better.  I gotten this far by looking in the manual, searching the forum and trying out Densmings good You Tube videos but now I need help.

My character (cOskar) has got an inventory object (iShoppinglist) by a dialog so it is in his inventory.

I wish to make it so that when he looks at it (“It’s the shoppinglist I got from Mum”) it says it’s the shopping list but but then he looks at in again (or interact with it) it change from object iShoppinglist to object iMap (“Look something is written on it back”) (Player found new quest item, gets score).

Is that possible to make? I know that there is no interact button in the inventory in the Default game, I read something about using “talk to”? Or should I change the name of the item and keep picture if that easier?

Please, someone help me and please keep in mind that I just started and no nothing about scripting and excuse my bad English. Thank you.

ThreeOhFour

It sounds like you're looking for something like this:

Code: ags

function iShoppinglist_Look()
{
  if (Game.DoOnceOnly("listlook"))
  {
    player.Say("It's the shopping list I got from Mum.");
  }
  else
  {
    player.Say("Look, something is written on the back.");
    player.LoseInventory(iShoppinglist);
    player.AddInventory(iMap);
    GiveScore(1);
  }
}


Hope this helps!

BlueAngel

#2
Thanks, I will try that! :)
It worked, thank you!

BlueAngel

Sorry for opening this again but I thought it was better than to start a new one.
I tried Ben304 solution and it worked great but then I wanted to do it again and somehow I messed it up because this time it didn’t work.
I looked up DoOnceOnly in the manual and so far as I can tell you can use it more times as long as the string is different?


This is how my code looks like, someone please help.

The first one works (listlook), its the Cheeselook that dont work. The cheese is in the inventory and I dont get any wrong message but nothing happens when i look at it (in the inventory)


Code: ags
function iShoppinglist_Look()
{
  if (Game.DoOnceOnly("listlook"))
  {
    cOskar.Say("Its the shoppinglist I got from Mum.");
  }
  else
  {
    cOskar.Say ("Funny it seams like something is written on the back of it!");
    player.LoseInventory(iShoppinglist);
    player.AddInventory (iGameIdea);
    GiveScore (5);
}
}

function cMum_Look()
{
  cOskar.Say("Thats my Mum!");
}



function iGameIdea_Look()
{
  Display ("Look, the game idea I wrote for my sisters game is written on the back! My mum must have take that paper by misstake");
  GiveScore(5);
}

function iCheese_Look()
{
  if (Game.DoOnceOnly("Cheeselook"))
  {
    cOskar.Say("Wow, thats is strange");
  }
  else
  {
    cOskar.Say ("How in the world did my mouse end up there?");
    player.LoseInventory(iCheese);
    player.AddInventory(iMouse);
    GiveScore(5);
}
  
}

Khris

Don't forget that the function has to be linked to the event, does it say "iShoppinglist_Look" in iCheese's events pane next to "look at inv item"?

BlueAngel

Thanks for trying to help me.
It does say "iCheese_look" in the Cheese event panel next to the "look at inv item" just like it does in the working example with the the shoppinglist.
I cant se any differents between the two so it should work but it doesnt?

Lufia

You said "iCheese_look".

Is that a typo and you meant 'iCheese_Look" like in your code or is there really a problem here ? Try deleting the function in the events pane then clicking on the button with the three dots, it should link to the function properly.

BlueAngel

Thanks for all help, I found out that the scrip is working, its just that you have to click at a strange place of the object to get the script to work. Probely got something to do with the Inventory item cursor hotspot marker or my resolution? I post a new post when i got more information.  ;)
Thanks so much for helping me!

SMF spam blocked by CleanTalk