Automatic doors

From SCI Wiki
Jump to: navigation, search

By Cloudee1

When using Doors and AutoDoors, I am not sure why but things always seemed to go awry. This little tutorial will have a simple Automatic Door (when the player walks near them, they open) up and running with two simple lines of code.

We begin at the very top of the script. We will need to tell the script that we are going to be using an automatic door and to include that functionality. This is done simply by adding in another use command where all of the others are.

(use "autodoor")

Now that one line is finished, lets go on to the second one, the hard one. Just kidding, there is nothing hard to this method of using automatic doors. The script can now handle AutoDoor instances now, but we are not making one of those, at least not the traditional way. In the rooms init method, where you init() your rooms views and actors, you will need to add in the call that inits the automatic door. the parameters are of the basic type, and I don't think it's necessary to go into detail about them.

(send (AutoDoor:new()):view(211)
                       posn(161 62)

At this point, as long as you have added the doors view, and have set up the doors control colors Navy and Green (you won't need a Yellow one because this type of door does not get blocked) for when to open or transport to a new room. We don't need to create an instance or anything else, we are all done coding.

This simple type of door has some limitations though, because there is not an instance name to reference you won't be able to program interactions with it as the code stands now. So keep this in mind. This door can't be locked or blocked, if all you need is a door that opens when you near it, then this will work.

For more advanced needs, such as multiple doors in the same room, see Advanced Use of Control Areas