Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: jpcr on Sat 27/02/2010 22:38:56

Title: [solved] oMyobject.Move(..); in a function
Post by: jpcr on Sat 27/02/2010 22:38:56
hi,

i would like to run a script doing :

oMyobject.Move(320, 480, 1,  eBlock, eAnywhere);

when it is inside the room script , no problem.
but i would like to be able to apply this same move for all my objects so i tought i could use a function.

i dont know how to pass the object referene to the function.heres my code :

in globalscript.ash :
import function getrid (Object);

in globalscript.asc :
function getrid(Object myObject )
{
 
 myObject.Move(320, 480, 1,  eBlock, eAnywhere);

}



in the room :

getrid(oChaussette);

i get an error : Failed to save room room1.crm; details below
room1.asc(11): Error (line 11): Type mismatch: cannot convert 'Object*' to 'Object'


any help would be appreciated!!

thanks
jp



Title: Re: oMyobject.Move(..); in a function
Post by: monkey0506 on Sat 27/02/2010 22:44:41
In your function it should be a pointer, such as:

function getrid(Object *myObject)

It should have caught that you weren't making that a pointer to begin with..but that seems to be the reason why.

Read the manual entry on pointers..it should help clarify for you the differences.
Title: Re: oMyobject.Move(..); in a function
Post by: jpcr on Sat 27/02/2010 22:46:46
mm yes but i still have the same ompilation error.

function getrid(Object *myObject )
{
 
  myObject.Move(320, 480, 1,  eBlock, eAnywhere);

}
Title: Re: oMyobject.Move(..); in a function
Post by: monkey0506 on Sat 27/02/2010 22:58:33
Sorry, the import should also be such as:

import function getrid(Object*);
Title: Re: oMyobject.Move(..); in a function
Post by: jpcr on Sat 27/02/2010 23:01:08
fantastic , it works great.

thanks so much  :D

jp