Prospero's pages

Updated July 23, 2005



Tut 11. Doors.

There are two methods of making doors. The first uses a sliding sector bulit into the map in the LED. The second uses an object which is moveable. I will refer to the latter as Gates rather than Doors. Most Gates in the game use the 'Portcullis' type object. (

Doors need carefull construction in the LED. A simple one would be a doorway split into three sectors. The middle sector will be the sliding part. The outer two form the frame. A sliding sector needs to ajoin one sector only or you get weird stuff happening. Remember this if you want to make double doors. Each half should match it's own outer sector. Don't be tempted to bridge the two halves with one big outer sector. You can arch the outer sectors, but keep the sliding part square. You will need a set of coords from some point within the slide sector.

Time for a new file. (There is a source file
Exec in as per usual.

import Doors
import Levers
import Locks
import Objects
import Sounds
import Sparks
import darfuncs
import Stars

Before making the door, define a few sounds at the top of file:



The first sound is played while the door is sliding. Second is the clunk at the end.

Now create the door:

# assign the sounds you defined above door1.SetWhileOpenSound(snd_doorslidewood) door1.SetWhileCloseSound(snd_doorslidewood) door1.SetEndOpenSound(snd_doorhitwood) door1.SetEndCloseSound(snd_doorhitwood)

You will see that there are a lot of parameters associated with a door.

From the top you have the individual name

Next you have the coords of the sector in

Next another
() with three args 0,1,0. This sets the direction the door will slide. 0,1,0 makes it slide up from closed position. 0,0,1 would make it slide sideways along the Y axis. 1,0,0 along the X axis.
Making the
1 negative in each case will make it go in the opposite direction along the same axis. (No, you can't make them go diagonally.).

The next arg '
500' is the amount that will be left sticking out when the door is closed. The next is the dimension of the sector on the axis the door is set to slide along. In this case 6 LED units which translates to 6000 in the script.

The last is fairly obvious.
Doors.CLOSED means the door is created closed. Put Doors.OPENED (not OPEN) and it will be created in the open position.

Below are more settings (not all of which I fully understand).

Ignore the first
Doors.UNIF (Always use this).

o_med_vel sets the speed it will open.

o_med_displ .To get this value, subtract the amount you set above to have sticking out when open from the dimension of the sector you also set above. 6000-500=5500.

Ignore the

The next two with the prefix
c are the same as the ones with prefix o but they do the same jobs when the door closes.

It may seem all very confusing at this point but stick with it.

The code that handles the doors is very powerful and can make them do all sorts of things, but for the mo use the above code as a template.

Before doing anything else, load the map and go to your door. It should be shut. Have a good look from both sides and see if you notice any weird effects.

A word about textures here. It is tricky to assign textures to doors. Even if you align the texture with OGL veiver before making the slide part, you will find that the texture can move when the door code is applied. A bit of guesswork is usually needed.

If all is well you now need a means of opening it.

Usual method is a lever and the usual lever is the familiar

A lever has two parts: the plate and the stick. You need only get coords for the plate. The lever is made automatically when you apply the lever data. For accuracy, you should ideally use the Entity Browser to get a good placement, but for now we will use 'dead reckoning.

On your
.mp file, place you cursor on the wall roughly where you want the lever and note the XY coords. You need it about 1 meter up from the floor. For Orientation use these:

(0.5,0.5,0.5,-0.5) # to face west
(0.5,0.5,-0.5,0.5) # east
(0.0,0.0,0.5,-0.5) # north
(0.707,0.707,0.0,0.0)# south

If you want it diagonal, you really need the
EBrowser. btw. if you look carefully there are some oily dribbles on the plate. Keep these going down to get it the right way up. The stick part will operate in the wrong direction otherwise.

OK create the lever with:

door1lvr=Levers.PlaceLever("Door1Lever", Levers.LeverType3(5000,-1000,-4000),(0.707,0.707,0.0,0.0),0.8)

So you have the individual name of the lever, the type of lever, the coords of the plate and the
Orientation of the plate.

The last arg,
0.8 is for the scale. BUT as far as I can tell this is not used. All the levers will be scale 1.0. However, the syntax demands that a value must be put here, so leave it as it is and forget it.

The mode affects how the lever operates.
1 will make it spring back, set to 0 and it will stay down when operated.

Next, the open/close functions are assigned. Define these in

def OpenDoor1():

def CloseDoor1():

You will notice that you can put in arguments to be passed with the function if you want. Having said that I have yet to find an example in the game where this is used. You can probably omit these two lines.(?)

OK. You should now be able to open and close your door. Don't be downhearted if it doesn't work first time. Doors are quite complex and lots of things can go wrong.

Other Levers.

If you use other levers, you will have to put the type in the
Levers.LeverType3 bit.

LeverType3 is the "Zocalo3" type plate

LeverType1 is the "Zocalo1"
LeverType2 is the "Zocalo2"
LeverTypeFloor is the "ZocaloSuelo" # not used in game, but they do work.
LeverTypeSnake is the "ZocaloSerpiente" # not used in game and I have never tried them.

I'll do Locks when I do Gates.

Next Lesson....De-Bugging.