how to: Inventory item to open a door

Started by shaungaryevans, Thu 23/10/2008 17:22:56

Previous topic - Next topic

shaungaryevans

hi,

I've got a key as a inventory item and i got a locked door. I only want to open the door when the inventory is used and nothing else. Can somebody please tell me how to do it please?

RickJ

1. Create key inventory item
   - right click inventory in navigation tree
   - select Create new inventory item
   - change name to iKey

2. Create an object in the room and name it oDoor.
   - room edit
   - select object from drop list
   - right click on room background

3. Create a "use inventory on object" event handler function
   - room edit
   - click (lighting bolt icon in properties window
   - click "use inventory on object"
   - clcik "..." button

4.  Edit event handler
   - Add the following code
Code: ags

if (player.HasInventory(iKey)) {
  // Unlock the door animation here
}

Khris


RickJ

Thanks Khris, I look everywhere for that and could't find the @$#% %$#!@ thing.  :=

By all means use player.ActiveInventory instead of player.HasInventory().

shaungaryevans

#4
Thanks for that, but it still won't work. The Output window box is saying'  Parse error in expr near 'Cchar' when I put in the following code:

function hdoor1_UseInv() {

if (cChar1.ActiveInventory(iKey))
{Shaun.ChangeRoom(0)} ;

Please tell me where I'm going wrong?

Khris


shaungaryevans


SMF spam blocked by CleanTalk