Template ‐ OPENABLE - ThePix/QuestJS GitHub Wiki
OPENABLE
An openable object is like a container, but in the reverse sense of a surface - it can be opened and closed, but cannot hold something. When using the template, it takes a single Boolean, indicating whether it starts open.
If the item is a container, using the CONTAINER template, not this one.
The only important attribute is "closed". However, you can override the default open and close messages with your own msgOpen
and msgClose
strings.
createItem("secret_door", OPENABLE(false), {
loc:"lab",
scenery:true,
examine:'The door blends perfectly with the wall.',
msgOpen:"The door silently opens.",
msgClose:"The door silently closes, and is hardly noticeable.",
});
Other Attributes
The "openable" attribute will be true
.
If the item has "testOpen" or "testClose" attributes, these functions will be run before the item is opened or closed. If it returns false
the action is cancelled - the function should give a message saying why. If the item has "afterOpen" or "afterClose" attributes, these functions will be run when the item is successfully opened or closed, after the message is printed. All these functions are sent a diction with "char" set to the character doing it as a parameter.
Locking
If you want to lock your openable item, see here.