Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Barn Owl on Wed 02/04/2025 02:50:38

Title: oObject.Visible=false in dialog
Post by: Barn Owl on Wed 02/04/2025 02:50:38
Hi all,

I'm still a complete novice here, yet I am determined. I apologize if this question can be easily answered by consulting the manual.

As the subject suggests, I would like to make an object disappear by selecting a dialog option.

For example,

@S
return
@1
Ego: I'd like this object to disappear!

  oObject.Visible=false

stop

Right now I am getting the undefined token 'oObject' error, even though the name of the object is correct. Can anyone give me a helping hand making this damn object disappear via dialog?

Thank you so much for any help!
Title: Re: oObject.Visible=false in dialog
Post by: RootBound on Wed 02/04/2025 03:11:15
Hi Barn Owl,

I believe dialog scripts are considered global scripts, so they can't access room object names. To access a room object from a global script, you would need to do so using the object's ID number--for example, "object[1]" will refer to the object with ID number 1.

You can find the object's ID number by looking at the object in the room editor.

Then try:

object[ID number here].Visible = false
Title: Re: oObject.Visible=false in dialog
Post by: Barn Owl on Wed 02/04/2025 04:20:02
Thank you greatly, RootBound, that worked!

That's precisely what I suspected to be the issue, yet wasn't sure. My technical pea brain is slowly grasping this script.

I really appreciate the assistance! May your creativity continue to bloom.
Title: Re: oObject.Visible=false in dialog
Post by: Crimson Wizard on Wed 02/04/2025 10:55:39
Alternatively, there's CallRoomScript function that delegates this task to the current room script, where you can access everything by names, and also access room script variables:
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html#callroomscript

this may be more convenient if either:
- you need to do a lot of room changes in one go.
- you need to do different things depending on a room.