:ObjectOn: Invalid Object specified

Started by Jojowl80, Sun 09/08/2020 04:07:25

Previous topic - Next topic

Jojowl80

my game closes with this error message  :ObjectOn: Invalid Object specified
in reference to object 3

Code: ags


function hHotspot1_UseInv()
{
if (player.ActiveInventory == (iLasso))
player.Say("Okay.");
object[1].Visible = true;
sLever.Play();
object[2].Visible = true;
object[3].Visible = true;
sLadder.Play();
object[0].Visible = true;
RestoreWalkableArea(6);

}



I have all 4 objects set to false before the character throws a switch. So why 3 of them work and the other one does not.. I have no idea

Slasher

#1
For a start you had two missing braces:

Code: ags

function hHotspot1_UseInv()
{
if (player.ActiveInventory == (iLasso)) 
{
player.Say("Okay.");
object[1].Visible = true;
sLever.Play();
object[2].Visible = true;
object[3].Visible = true;
sLadder.Play();
object[0].Visible = true;
RestoreWalkableArea(6);
 }
}

Also check out your Object ID's..

Matti

Yes, doublecheck if there really is an object 3 in the room.

Also, it's better to give objects (and hotspots!) names. The code will be a lot easier to read and you can avoid referencing objects that don't exist.

SMF spam blocked by CleanTalk