global function with 2 variables [SOLVED]

Started by RocketBoy, Thu 21/07/2005 02:23:47

Previous topic - Next topic

RocketBoy

Hi everyone,

This is my first post and hopefully I am not going to go against some rule or something! I HAVE searched the Technical forum and Beginners Technical Questions without any success!

Here's my problem:

I'm trying to make a simple global function that would do the following each time the player would click on a object: 1) Walk to Object, 2) Add Object in inventory and3)remove object from the room.

So far my script is:
Global Script (right at the top):
Code: ags

function globGetObject(int zzObjectNum, int zzInvID){
character[EGO].Walk(object[zzObjectNum].x,object[zzObjectNum].y);
character[EGO].AddInventory(inventory[zzInvID]);
object[zzObjectNum].Visible = false;
}


Script header:
Code: ags


import function globGetObject(int, int);



On the Object script in a room:
Code: ags


globGetObject(0,3); 



I get this message when I try to save the game:
There was an error compiling your script. The problem was:
In: 'Global script'
Error (line 3):'y' is not a public member of 'Object'

(where line 3 is the 'character[EGO].walk' part)

I'm under the impression that I'm missing something obvious! :-\ Can someone point me in the right direction please? Or show me where the thread is if someone already answered that question somewhere else.

You already have the eternal thanks of a newbie!
---------------------------------------
++Ã,  ++Ã,  + Rocket Boy+Ã,  ++Ã,  ++
---------------------------------------

strazer

The Object.X and .Y properties have to be uppercase. ;)

RocketBoy

#2
Wow. That was simple, I almost feel stupid :-\

I was so certain it had to do with something else than a typo... ack I hate doing that kind of mistake!

Thanks Strazer!
---------------------------------------
++Ã,  ++Ã,  + Rocket Boy+Ã,  ++Ã,  ++
---------------------------------------

monkey0506

Question:  Why are some X & Y properties upper case, while some are lower case (i.e., mouse.x & mouse.y, versus Object.X & Object.Y)?  Of course if there is a mouse.X & mouse.Y property that may in some way be different...It seems like there might be but I don't have access to a manual ATM, so...

strazer

#4
Quote from: Pumaman on Mon 07/02/2005 20:51:48Because all the new OO properties start with a capital letter. So your question might be, why aren't the character x and y capitalised. The reason for that is that changing it would require people to rework tons and tons of code, for no real advantage.

monkey0506

Okay...thanks ;D

Which makes sense...

SMF spam blocked by CleanTalk