Global GUI local room [solved]

Started by Zipofthe95, Thu 27/08/2020 13:06:28

Previous topic - Next topic

Zipofthe95

Well that tells you bugger all.

Anyway, here's the gist. Let's say I have three four-button panels that use the same gui, and let's say the number 1 in each panel toggles the visibility of an object in a room. How would I go about it? I made a "panel gui" with "add gui button" but on click button sends me to global script. Global script doesn't work with local room objects (I just tried. I made an object 1 that controls that object within a room, works. On global script, it doesn't know what that object is). So essentially, is there a way to "localise" what a gui button does? And if that is possible, can I make the script carry over to other rooms? Let's say I have room 2 that's exactly the same room as room 1 (and panels use the same "panel gui") but while "button 1" there would control... a chair, room two "button 1" would control... a mug on the table. Hope I made myself clear.

P.S. On a side note. Can I make it that when I hover over a button a text appears to describe what it does. For example, if I have a "hand" button and mouse hovers over it to say in gui box "your hands "As efficent as they are deadly"?

Cheers!

Laura Hunt

You can reference room objects, hotspots, etc from your Global Script (or Dialogues, for that matter) by using their index rather than their script name.

So, instead of using "oWhatever.Visible = true", you would use "object[1].Visible = true".

Quote from: Zipofthe95 on Thu 27/08/2020 13:06:28
And if that is possible, can I make the script carry over to other rooms? Let's say I have room 2 that's exactly the same room as room 1 (and panels use the same "panel gui") but while "button 1" there would control... a chair, room two "button 1" would control... a mug on the table.

Yes, but you would have to make sure that the chair in room 1 and the mug in room 2 have the same index. And of course, be wary of possible side effects on objects with this same index in other rooms where the GUI might be active.

Zipofthe95

Yup, that's the stuff. Many thanks!

Crimson Wizard

I'd like to mention that there's also CallRoomScript function that lets you send a "message" to the room script, and in room script you catch it using "on_call" callback function (check them out in the manual). This is a method one may use to handle certain generic situation depending on the room you are in.


SMF spam blocked by CleanTalk