Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Snirpa on Sat 08/02/2014 12:28:23

Title: Error with Object[0].SetView(3);
Post by: Snirpa on Sat 08/02/2014 12:28:23
Hi there,

I'm exhausted googling and searching for an answer..I must be doing something simple wrong.

I want Set a view to an object. It is a simple house with some flashing lights. I want it to activate as the character enters the room.

Code (ags) Select


function room_Load()
{
Object[0].SetView(3);
Object[0].Animate(1, 3);

}

I get the following error.

Failed to save room room2.crm; details below
room2.asc(7): Error (line 7): fixed size array cannot be used in this way

I want to have a house in the background with some animated lights on it. My sprites are fine and I've created a View for them. Not I just want them to correspond with the object I placed.

Sorry for being such a noob.
Title: Re: Error with Object[0].SetView(3);
Post by: Mandle on Sat 08/02/2014 13:09:29
I think instead of Object[0] you need the name of the object...

Objects in AGS are named with a lower case "o" in the front of the name...

For example:

oTwinklyLightsCottage

You have to name the object in the room it's created in by selecting "Objects" in the room's dropdown menu, choosing said object, and then naming it in the "Name" blank...

I think this might help...Not sure as I have not yet used the specific function you refer to here...
Title: Re: Error with Object[0].SetView(3);
Post by: Khris on Sat 08/02/2014 13:12:54
Mandle is correct in that you can refer to objects and hotspots by their script name in room scripts. This won't work in the global script or dialog scripts however, and the error you've made is a simple one: it's object[0], not Object[0]. Object with a capital O is the name of the class while object[] is an array of pointers pointing to instances of that class.
Title: Re: Error with Object[0].SetView(3);
Post by: Mandle on Sat 08/02/2014 13:15:57
Quote from: Khris on Sat 08/02/2014 13:12:54
Mandle is correct in that you can refer to objects and hotspots by their script name in room scripts. This won't work in the global script or dialog scripts however, and the error you've made is a simple one: it's object[0], not Object[0]. Object with a capital O is the name of the class while object[] is an array of pointers pointing to instances of that class.

Hehe...

if (Me == Pwnd)
{
KhrisAdvice = true;
}
Title: Re: Error with Object[0].SetView(3);
Post by: Snirpa on Sat 08/02/2014 13:20:18
Doh.

Thanks Khris, that was indeed the mistake.

Feeling silly but happy because my house now has blinking lights :)
Title: Re: Error with Object[0].SetView(3);
Post by: Khris on Sat 08/02/2014 13:26:29
Btw, you can always check the suggestions of the auto-complete window. If you start typing "Obj", it'll suggest "object" with a pointer symbol and "Object" with a Class symbol. Furthermore, if you type "object[0]" then the dot, the window will list all the available functions and properties for objects, while it will only list the static "GetAtScreenXY" function for "Object." or "Object[0]."
Title: Re: Error with Object[0].SetView(3);
Post by: Snirpa on Sat 08/02/2014 14:03:06
Thanks again :) :)