oObject.Visible=false in dialog

Started by Barn Owl, Wed 02/04/2025 02:50:38

Previous topic - Next topic

Barn Owl

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!

RootBound

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:

Code: ags
object[ID number here].Visible = false
They/them. Here are some of my games:

Barn Owl

#2
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.

Crimson Wizard

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.

SMF spam blocked by CleanTalk