Problem with ActiveInventory()

Started by The Creator, Wed 04/01/2012 19:36:51

Previous topic - Next topic

The Creator

Hello, i've read all the FAQS and searched a bit this forum but i couldn't find an answer.

I've one room with one item and one hotspot that works with that item. I want to check if the player is using the correct item, but an error keeps poping up and i can't figure out what's the problem. Here's my code:


Quote

function hCar_UseInv()
{
    if (player.ActiveInventory() == iKey)
   {
       Display("The car is now open!!");
   }else{
       Display("You need a key to unlock the car");
   }
}


The message i'm getting, is the following one:

Failed to save room room1.crm; details below
room1.asc(32): Error (line 32): Parse error in expr near 'player'


Could you please tell me what i'm doing wrong? If i use the hasInventory() property instead, it works just fine =S.

Khris

#1
It's player.ActiveInventory, without the brackets. It's not a function, it's a property, and is accessed like a variable/pointer.

Not sure how you missed this in the manual and the forum search but I guess it happens.

(Btw, .HasInventory() is in fact a function and needs a parameter, hence the brackets.)

The Creator

Thank you very much, it was that.

It was a bit weird, because i had the doubt about the function or propertie thing and i remember trying it without the brackets.


Thanks, again.

SMF spam blocked by CleanTalk