- Let other scripts know that a door has been opened/closed
- Open/Close your doors from other tools, including AVsitter, MLPv2...
This tool provides a simple scripting interface that will allow you to:
- Know within other scripts when the doors are opened or closed
- Use other scripts to open or close a door, bypassing any access control setting
The second allows us to use the door script so we can open/close our doors even from tools like MLPv2 or AVsitter. Read the "OPEN/CLOSE YOUR DOORS FROM OTHER TOOLS, INCLUDING AVsitter, MLPv2..." section to know how :-)
LET OTHER SCRIPTS KNOW THAT A DOOR HAS BEEN OPENED/CLOSED
Each door sends a llMessageLinked when it's opened, and when it's closed. This will allow us to know if a door is opening or closing from any script that we place in the root prim, should we need it. The messages sent are:
llMessageLinked(LINK_ROOT , 50999 + linkNumberForTheMainDoorInTheGroup , "DOOR_OPEN", avatarID); llMessageLinked(LINK_ROOT , 50999 + linkNumberForTheMainDoorInTheGroup , "DOOR_CLOSED", avatarID);
There's a full perms script supplied as an example of how to read and work with the messages that the doors send: "[Black Tulip] Processing link_message". If you add this script to your doors, particles will follow the avatar clicking the doors while they're open. The code is commented so it's easy to understand how to work with this (simple) interface.
OPEN/CLOSE YOUR DOORS FROM OTHER TOOLS, INCLUDING AVsitter, MLPv2...
Now, we would like to go the opposite way: make another script send our doors a message, so a specific door is opened/closed.
Think of this example to understand the usefulness of this feature:
Suppose you have a bed with a multipose engine. Suppose this bed has a cover/quilt that you would like to "show" or "hide", this option being a part of the multipose engine menu, like AVsitter or MLPv2.
This quilt could be a prim that you want to resize depending on an "open" (show) or "close" (hide) state, and so the menu from the multipose engine could tell the doors script to activate the right state.
This quilt could be made of two prims, each one being the quilt when "open" (show) or "close" (hide). By resizing to very small and moving inside another prim in our "door" setup, the cover that shouldn't be seen in the open/closed state, we could record such a configuration. Then, we later allow the menu from the engine to "open" or "close", showing thus the right prim, effectively giving the user a quilt they can open or cover themselves with.
Whichever decision you take about how to set this quilt as a "door" that "opens" (shows/covers avatars/etc.) and "closes" (hides/resizes to smaller/etc.), you can later make any other script activate the "open" and "close" functions.
OPEN/CLOSE YOUR DOORS FROM OTHER TOOLS, INCLUDING AVsitter, MLPv2...
THE GENERAL WAY
There are two linked messages we should send here, both using the -718640983 code:
Open#DoorName To make the script open the door DoorName Close#DoorName To make the script close the door DoorName
So you should add at some point of the script that is to open/close the door, one of the two following lines of code:
llMessageLinked(LINK_ROOT, -718640983, "Open#DoorName", toucherKey); llMessageLinked(LINK_ROOT, -718640983, "Close#DoorName", toucherKey);
IMPORTANT: DoorName is the common group name of all the prims belonging to a door! We will not be using DoorName#1, DoorName#2, etc, we will ONLY be using DoorName.
IMPORTANT: Using this method overrides any access setting for the door. Indeed, you could set for REACTS_TO_TRIGGER the value 0 if you want the "door" to be operated only via menu.
Your package contains a script sample that shows you how to do this. It's a simple example that, on touch, alternatively opens and closes a door called "d1".
OPEN/CLOSE YOUR DOORS FROM OTHER TOOLS, INCLUDING AVsitter, MLPv2...
USING MLPv2, AVsitter...
Now, not everybody is script-savvy, and most likely we are going to use this in multipose engines anyway, so this feature is actually easier to setup.
If you work with MLP, you can easily add a "Open Door" button in the main menu by adding the following line in the .MENUITEMS notecard:
LINKMSG Open Door | 1,-4,-718640983,Open#DoorName
Open#DoorName would be here the message passed in a llMessageLinked call, it being DoorName the name of the door.
Then, similarly we can add a "Close Door" button by adding the following line in the .MENUITEMS notecard:
LINKMSG Close Door | 1,-4,-718640983,Close#DoorName
Your package has a .MENUITEMS notecard with this included, so you can study how and where to add it.
If you work with AVSitter it is also easy to add a couple of buttons in the main menu to open/close a door named DoorName. All you have to do is to include two lines such as:
BUTTON Open#DoorName|-718640983 BUTTON Close#DoorName|-718640983in your AVpos notecard.
Your box has an AVpos notecard with this included, so you can study how and where to add the lines above.
Very easy to use, and you can add quite a lot of value to your build this way.