Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sparky on Thu 23/11/2006 07:40:40

Title: toggle object visibility in character script (solved)
Post by: Sparky on Thu 23/11/2006 07:40:40
Hello, and good day to you all. I'm wondering if it is possible to toggle an object's visibility from within a character's script. My first effort was this:
// script for Character 2 (man): Talk to character
   oThing.Visible = false;
When I try to test the game, I receive the following error:
"Error (line 408): Undefined token 'oThing'"
I presume this is because the object in question isn't local to the character script. Perhaps there's a way to call a room function from within this character's script, and then change the object's visibility from the room script?
Title: Re: toggle object visibility in character script
Post by: SSH on Thu 23/11/2006 08:48:34
If the character is only ever in one room, you can just use object[WHATEVERNUMBER].Visible
Title: Re: toggle object visibility in character script
Post by: Khris on Thu 23/11/2006 09:02:38
And there's CallRoomScript(); (http://www.adventuregamestudio.co.uk/manual/CallRoomScript.htm)
And you can check the current room using player.Room (http://www.adventuregamestudio.co.uk/manual/Character.Room.htm).
Title: Re: toggle object visibility in character script
Post by: Sparky on Fri 24/11/2006 05:22:54
Great, that works perfectly. The script now uses a player.Room check, then sets object[number].Visible = false. I'm going to mess with CallRoomScript() as well, I'm sure that will come in handy in a lot of situations. Thanks for the help, I wasn't having any luck finding answers to that question via the usual means.