Swing Door Opener BRIGADOON-0006
This script controls the opening and closing of a door (or window)
Loading...
Searching...
No Matches
2 PROJECT DESCRIPTION

Section 2.1 - Project Overview

This project deal with swing doors in Open Simulator. There a plenty of scripts around that adeuately open and close doors, but some of them have a significant defect that may not be immediately obvious until the the door is open when the simulator has an abnormal shutdown.

In these cases, the curent state of the door may be lost and when the simulator restarts, it assumes that the door is closed. A subsequent command to toggle the door state results in the door moving to an incorrect position.

To overcome this problem, the door needs to know where the closed position is so that it can swing between the correct positions. The ultimate solution is to be to store the closed location and the open/closed state though a simulator restart. Alternatively, knowing the closed state and forcing the door to that position and setting its state as closed can be a viable option is most cases.

It is also possible to save the current state using things like KeyValue pair susing llCreateKeyValue() and llReadKeyValue(), but they require the use of the datasever, complicating the design. The routines llLinksetDataRead() and llLinksetDataWrite() provide a simpler method of reading and storing data.

For this solution, the door is set so that it knows what its closed location is, rather than just assuming that it is starting in the closed position, it forces the door into a closed position. Knowing the absolution location of the door complicates things if the position of the door is shifted. In that case, the absolute locations stored the script need to be altered. To over come this problem, the door is mounted in a frame as part of a linkset. In this case, the location of the door is determine relative to the door frame. If the door fame is moved, the position relative to the frame does not change, so the script does not need to be changed.

Once the door is in a link set, the door can either be controlled by a script in the root prim or by a script in the door. For this exercise, the control script is installed in the door prim so it can be more easily controlled individually.

The documented example is for the double doors that provide the entrance to the Glass Pyramid in the centre of region "Brigadoon13" in the "little-sense.au" simulator.

                                        hop://little-sense.au:9000/Brigadoon13/342/360/32

In addition to the opening and closing by touching, the door can open of close by contact. The door can be locked to disable the ability for anyone but the owner to open or close the door by any means. the owner is exempt from the state of teh lock, so that entry is even possible if the doors are locked from the inside.

Section 2.2 - Doorway Components

The doorway for this construction consists of five components:

  • Door Lintel The horizontal beam that goes across the top of the doorway. It should be at least width of the doorway.
  • Door Jambs There is a door jamb on either side of the lintel. It should be at least the width of the door's thickness, but it's width can be as wide as the door lintel or wider for effect.
  • <D>Doors In this instance there is a left door and a right door placed between the door jambs and touching in the middle. There are essntially just rectangular slabs that are notmally equally sized.

The name of the lintel, jammbs should be set to make it obvious what they are, typically, lintel, left_jamb, right_jamb. The doors should be named left_door and right_door.

Section 2.3 - Doorway Construction

The lintel and the jambs are textured with the default "hardwood" texture and a brown tint to suit the building.

The doors are placed in between the door jambs so that join in the middle. If you have problems aligning the doors, one trick is to go to the object menu and copy the location of one door that is in the position yoou want it. Thengo to the object menu of the other door and paste in that position. The doors wil now perfectly overlap and it is simply a matter of dragging a door to the other side of the door jamb so they just touch in the middle. In this case the "doubledoors" texture was used. It was used on all faces, so it is also on the backfaces of the doors. The scale and offset can e used to make sure that images are correctly aligned on the doors. It should be noted that this method places the textures on the edges of the door and each of thise faces should be changed to a match colour to make the door look more realistic, but that can be more easily done once teh swing doors work. Alternatively. you can do this before putting the doors in place.

Once the door has been assembled, it is time to link all the components together. Select all items similar to this, ensuring that lintel is the last object selected and then link: left_jamb, right_jamb, left_door, right_door, lintel.

Since the lintel was slected last, it becomes the "Root Prim" which will be important later.

Section 2.4 Finding Local Closed Position

If each of the doors is selected using "edit linked" and the "object" menu, the Position shown is the position in the region. What is really required is the position of the closed door relative to the root prim which is the lintel. To save some calculations,install the script get_linked_localPositions.lsl and reset. You should get a message like below in "Nearby Chat":

[21:30] Glass Pyramid Door Set: Left Local Pos = <-0.018646, -1.454590, -0.676590>
[21:30] Glass Pyramid Door Set: Left Local Rot = <-0.000000, 0.707107, 0.707107, 0.000000>
[21:30] Glass Pyramid Door Set: Right Local Pos = <-0.019852, -1.462891, 0.643234>
[21:30] Glass Pyramid Door Set: Right Local Rot = <-0.707107, 0.000000, 0.000000, 0.707107>

Note this information, becasue it will be used to tailor your door scripts to ensure that the door will alwas end up aligned with the lintel if if there is a crash. Once you have recorded this information, delete this script.

2.5 Installing the Individual Door Scripts

The left hand and right hand door scripts are essentially identical except for two things. First the local position inforamtion is diffrent because tehy are in direction locations and secondly, they are swinging from the opposite side of the door.

The first things to do is insert the values that you found running the previous script, then you should look at the intSwing value and it should be the opposite sign of the other door. That is, instead of being -90, it should be +90.