(SOLVED) Useing inventory object on object in order

Started by BlueAngel, Sun 06/12/2009 12:33:14

Previous topic - Next topic

BlueAngel

Hi everyone, I need help again.
I’m using the AGS (3.1) and I have looked in the manual and searched the forum but I can’t found the answer.

The goal of my game is to found five things and the putting them together to get a six item and I want the player to put them in a order.
I think I can do this with a if or else statement but not sure how?

This is what I have done so far: Place inventory object 1 on hotspot turning it to an object. Use inventory 2 on object, making it disappear and give the player points, if the player take another object then 2 - display message.
How do I go from there? I want it to check that the player puts object 3 next and nothing else and that object 2 is there first?
Sorry for my bad English, hope someone understands and can help. Here is my code.

Code: ags

function hDesk_UseInv()
{
  if (cOskar.ActiveInventory == iComputer) {
    cOskar.LoseInventory (iComputer);
    oComputer.Visible = true;
    GiveScore (5);
  }
}


function oComputer_Look()
{
  cOskar.Say("My old trusty friend!");
}

function oComputer_UseInv()
{
  if (cOskar.ActiveInventory == iKeyboard){
    cOskar.Walk(260, 483, eBlock, eWalkableAreas);
    cOskar.Say("Good, now Im starting go get somewhere but where is my mouse?");
    cOskar.LoseInventory (iKeyboard);
    GiveScore (5);
  }
  else 
    cOskar.Say("I need to put something else there first");
    
}


Khris

To check if a certain item has already been placed, simply check if the corresponding object has already been turned visible.

Code: ags
function oComputer_UseInv()
{
  if (cOskar.ActiveInventory == iKeyboard){
    cOskar.Walk(260, 483, eBlock, eWalkableAreas);
    cOskar.Say("Good, now Im starting go get somewhere but where is my mouse?");
    cOskar.LoseInventory (iKeyboard);
    GiveScore (5);
  }
  else if (player.ActiveInventory == iMouse) {
    if (oKeyboard.Visible) {
      ...
    }
    else player.Say("I need to connect the keyboard first.");
  }
  else cOskar.Say("I need to put something else there first");
    
}

BlueAngel

Thanks for helping me out again Khris!

I wasn’t planning on making a object for every inventory item but maybe I have to (and it’s the easiest way out)?

If I do so can the objects be at the same place? So I make oComputer invisible and oKeyboard visible but they need to be at (almost) the same place? (on the desk (a hotspot))

monkey0506

If the items have to be placed in a specific order you could use the Graphic property directly instead:

Code: ags
function oComputer_UseInv()
{
  cOskar.Walk(260, 483, eBlock, eWalkableAreas);
  if (cOskar.ActiveInventory == iKeyboard){
    cOskar.Say("Good, now Im starting go get somewhere but where is my mouse?");
    oComputer.Graphic = COMPUTER_WITH_KEYBOARD_SPRITE_SLOT_HERE;
    cOskar.LoseInventory (iKeyboard);
    GiveScore (5);
  }
  else if ((cOskar.ActiveInventory == iMouse) && (oComputer.Graphic == COMPUTER_WITH_KEYBOARD_SPRITE_SLOT_HERE)) {
    oOskar.Say("Great, now I have the keyboard and the mouse connected!");
    oComputer.Graphic = COMPUTER_WITH_KEYBOARD_AND_MOUSE_SPRITE_SLOT_HERE;
    cOskar.LoseInventory(iMouse);
    GiveScore(5);
  }
  else 
    cOskar.Say("I need to put something else there first");
    
}

BlueAngel

Hi Monkey, please bear in mind that I’m new and my English isn’t so good, do you mean that instead of making a new object I change the graphic on the old one?

And then you write “oComputer.Graphic = COMPUTER_WITH_KEYBOARD_AND_MOUSE_SPRITE_SLOT_HERE;” is it the spirit number I should put there instead of the word you have put there since sprites don’t have names or?

thanks for all help! :)

monkey0506

Hey sorry if I wasn't quite clear enough. That is what I meant, that you can change the .Graphic property of the existing object to a new sprite instead of creating a whole new object.

And yes, the long capitalized nonsense bits are in fact supposed to be replaced with sprite numbers. So basically you would start off with the graphic as just the computer with no keyboard and no mouse.

Then when the player uses the keyboard you would change the graphic to the sprite of the computer with the keyboard (in the same sprite). And then the same thing with the mouse. ;)

Hope that makes a bit more sense. If not I could try and use some type of internet translator to produce a response in your native language...(though no guarantees how reliable they might be). 8)


SMF spam blocked by CleanTalk