I have some script that runs if an object exists in the room but I get a "invalid object specified" error.
function on_event (EventType event, int data)
{
if(event==eEventEnterRoomBeforeFadein)
{
if(version==0)
{
Room.SetProperty("versionnumber", 0);
}
}
}
int remtime;
// called on every game cycle, even when the game is blocked
function repeatedly_execute_always()
{
if(Room.GetProperty("versionnumber")==0)
{
if(object[0]!=null&&object[1]!=null)
{
object[0].Visible=true;
object[1].Visible=true;
}
if(object[2]!=null&&object[3]!=null)
{
object[2].Visible=false;
object[3].Visible=false;
}
}
if(Room.GetProperty("versionnumber")==1)
{
if(object[0]!=null&&object[1]!=null)
{
object[0].Visible=false;
object[1].Visible=false;
}
if(object[2]!=null&&object[3]!=null)
{
object[2].Visible=true;
object[3].Visible=true;
}
}
Object* o=Object.GetAtScreenXY(mouse.x, mouse.y);
if(o!=null&&mouse.IsButtonDown(eMouseLeft))
{
o.Graphic=15;
o.Graphic=16;
GiveScore(-1);
}
}
How can I check if an object exists in the room?
Please tell, on which line exactly do you get "invalid object specified" error?
I don't know what is going on in your game, but you probably also need to test the Room.ObjectCount to know how many objects are there, before accessing object[] array; because if there are 0 objects then you should not get object[0], and so on.