-
Notifications
You must be signed in to change notification settings - Fork 11
Library: Lifts
NOTE: If working on-line, you will be unable to use this, as custom libraries cannot be used.
NOTE: This is for version 2.1. If you have previously used version 2.0 and are upgrading to 2.1, and you have overridden the LeavingTheLift note that this now needs to output a string. See below for the default code.
NOTE: This does not work well with the map. See here for more.
Using this library you can easily implement one or more lifts (or elevators) in your game. Each lift can stop at any number of floors. Of course, you could apply this to any transport system that involves stepping into a location, and pressing a button, then stepping out at the destination.
To implement, create a room that will be the lift, and in it put a number of objects that will be buttons. You will obviously need one button per floor. For each floor, create an exit that goes to the lift room (but not the other way), also create a single exit for the lift room (does not matter where to).
For each exit going to the lift, on its attributes tab, add "liftentrance" as a new type (do not do this for the exit in the lift room).
For each button, on the Lift tab, set it to be "Lift Button", assign a floor number and a destination for each (i.e., where the lift will exit to when this button is pressed). There are text fields you can fill in, but they are optional.
For the lift room itself, on the Lift tab, set it to be a "Lift". Again, the textfields are optional. You can use ### in these strings and this will be replaced by the destination floor.
This system could readily be used for other systems that move at the push of a button, for example a shaceship for dummies! On the lift object, remove the going up and going down messages, but on the buttons, add descriptive departure and arrival messages, such as:
The clamps were released, and the ship fell away from the rotating spacestation.
Ahead was the space station, slowly rotating. The ship matched rotation, as its nose penetrated the centre of the wheel-shaped structure.
In this case, the floor name might be Spacestation, and the button could be called: "Spacestation" button.
Note that as implemented the player does not have to press a button to call the lift - the lift is automatically at whatever floor the player wants to get on at. You might want to have the lift entrances locked, and require the player to press a button to call the lift, which then unlocks the exit.
The library has support for setting this up, but you have to do some of it yourself. The problem is deciding when and what gets locked. If the player steps into the lift, does the door shut at that point, or only when the player goes to a different floor? When the player steps out of the lift, does the door close immediately, or does it wait for a few turns. These are decisions you need to make. However, the functions below should make this relatively easy to implement, by overriding LeavingTheLift, and using LiftExit and LiftAllEntrances to get all the exits, and then locking them.
The LeavingTheLift function is called when the player leaves the lift, after the leaving message is displayed (if there is one). It does nothing, but can be overridden as required, for example to lock the lift doors as mentioned above.
This function should print the leaving string, if there is one, so the default code is:
if (not this.leavingmsg = "") {
msg (this.leavingmsg)
}
This is called when the player presses a button, after the lift has been moved. Again it can be overridden as required. It takes three parameters, the button, the string telling the player what happened, and a flag that will be true if the lift did move, and false if it did not (player pressed the button for the floor it is already on).
This function should print the string, so the default code is:
msg(s)
If you want the lift to move for some reason other than the player pushing the button, invoke the move script on the relevant button. For example, if an NPC enters the lift and presses the button for the top floor:
do(top_floor_button, "move")
As of version 2.2, you can give a button a "lockedmessage" attribute (you can set it on the Lift tab). When the player presses a button, if this attribute is set, the message this will be printed, instead of the lift moving. This provides a way to lock each button.
You can unlock the button by setting the attribute to null.
This code goes one set further, and will unlock the button "button_third" for three turns, but will then lock it again. This could be used on a card reader or keypad perhaps.
button_third.lockedmessage = null
msg ("The third floor button is now useable!")
SetTurnTimeout (3) {
button_third.lockedmessage = "Access denied"
}
If you have set the "lockedmessage" in the editor and realised you no longer want it set, go to the Attributes tab and delete the "lockedmessage" attribute there, rather than just deleting the text on the Lift tab.
There are a number of other functions that can be used to find other parts of the lift system. All of them take an object as the only parameter; this can be either the lift itself or one of its buttons.
-
LiftRoomsimply returs the room that is the lift. -
LiftExitreturns the exit from the lift room. -
LiftCurrentFloorreturns the room that the lift exit goes to, i.e., the floor the lift is currently at. -
LiftCurrentButtonreturns the button that takes the lift to the current floor. -
LiftAllButtonsreturns an object list of all the buttons in the lift (this will include any that are invisible or scenery). -
LiftCurrentEntrancereturns the exit from the current floor into the lift. -
LiftAllEntrancesreturns an object list of all the exits into the lift. This is built from the buttons in the lift; if you have an exit to the lift without a corresponding button, it will get missed. If you have a button for a floor without an exit into the lift, it will throw an error.
To use this with another language mostly just involves settng the attributes in your own language.
However, you will need to override the "press" verb. Bottom left of the editor, do Filter - Show library elements. At the top of the left pane, type "press" in the search bar, and enter. This will display all the built-in parts of Quest with "press" in their name. Top of the list will be the "press" verb. Select it, then click the "Copy" button, top right.
Change the pattern and expression as appropriate. Do NOT change the name or attribute; these must both be "press".
Do not start the player in the lift!
Only have one exit on the lift room itself.