can someone give me a hand please

Started by barefoot, Tue 01/12/2009 14:33:42

Previous topic - Next topic

barefoot

Hi

I have not seen an answer to my query...yet

what i am trying to do involves 'inv' on 'obj'..

There are 4 objects in a room  that you collect and add to 'inv'...

There is a board where you click on empty boxes with 'inv' items.

The board contain switched off (invisible) objects. If the right 'inv' item is used that 'obj' becomes visible. If it does not match the 'obj' it just displays a message like "Does not match"... 

So, if you use the correct 'inv' on the object it switches on, and of cause you loose that 'inv' item.

Objects are: ochair, obird, ostar, owheel
Inventory objects are: chair, bird, star, wheel

so chair inv on ochair switches ochair on and you lose inv chair..  etc etc

can someone give me a hand please

barefoot








I May Not Be Perfect but I Have A Big Heart ..

monkey0506

#1
I like how descriptive the title of this thread is and how just by reading that subject I already know exactly what the problem is that you are experiencing and in no other way have to investigate to be able to determine whether or not I might have some relevant information to be able to assist you in resolving your problem.

In the room editor if you select the objects and then go to the Events pane (click the lightning bolt icon) there is an event for "Use inventory on object". So something like this:

Code: ags
function oChair_UseInv() {
  if (player.ActiveInventory == iChair) {
    oChair.Graphic = CHAIR_GRAPHIC;
  }
  else {
    player.Say("Does not match.");
  }
}


Rinse and repeat.

I am of course making the assumption that seeing as you were asking about using the inventory on the objects that when you say they are invisible you mean you actually have a transparent sprite associated with them and you're not actually setting the Visible property to false. Because if you're actually turning them off then this method wouldn't work and you would actually have to use the inventory items on something other than the objects that you're trying to use. But this method of using a single transparent sprite for the "off" objects and then just assigning the appropriate graphic when they're turned on probably is the easiest route.

barefoot

#2
Thanks  a lot monkey,

yes, i was using obj off then on...

i have a blank transparent image in the sprite.. could i use that so i could change the obj view???


oChair.Graphic = CHAIR_GRAPHIC;       would I for example, in this case, have a graphic of a chair named chair_graphic in my sprites folder  ??


UPDATE.. can use inv on objects (on) and messages of right or wrong come up..which is great) just need to make obj no been seen before inv used... can we change object to another???

thanks

barefoot
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

In the room editor try setting the object graphics to 0 (don't use any sprite). Then in the above code replace CHAIR_GRAPHIC with the sprite slot number of the sprite with the chair object's graphic on it.

SMF spam blocked by CleanTalk