Show pagesourceOld revisionsBacklinksBack to top Share via Share via... Twitter LinkedIn Facebook Pinterest Telegram WhatsApp Yammer Reddit TeamsRecent ChangesSend via e-MailPrintPermalink × Table of Contents Salet room CoffeeScript properties visited name title units canView canChoose priority displayOrder canSave ways choices maxChoices tags optionText dsc extendSection clear writers unitDelimiter CoffeeScript methods canExit exit enter entering take drop act register link bilink Salet room SaletRoom class is the class for Salet rooms. Rooms are the most important objects. CoffeeScript properties visited The number of times the player visited this room. A new room has it at 0. name Room ID. The engine uses this unique ID to find this room. Mandatory to have. title Name of the room. It's used in the list of ways generation ("you can go into these rooms: …") and possibly in browser history (the Back button, but that depends on the browser). You need this property if you plan to use the ways one. units An array of units placed in this room. You can set this when you create the room or populate it later. canView The flag that controls if the room is shown in an autogenerated list of choices. true by default. canChoose The flag that controls if the text optionText would be transformed into a link in an autogenerated list of choices. true by default. priority Used for sorting the choices before they are filtered by maxChoices. The sorting is in descended order, so a room with max priority stays in the list; a room with minimal priority is dropped. displayOrder Order of display; Used for sorting the choices after they are filtered by maxChoices. canSave The flag that controls if the player can save in this room. If salet.autosave is turned on, then the flag also controls if the room can be autosaved here. true by default. ways An array of room IDs; rooms that are available to go to from this room. The links are unidirectional, i.e. if you go somewhere from this room, you could't necessarily go back the same path. Using this array, the game constructs a list of linked rooms that would be printed in a special block. You can set ways when you create the room or use the link and bilink functions to manage the links. The bilink function is particularly useful, as it makes a two-way link. choices A list of tags or rooms used to generate an automatic list of choices. The tags look like #tag; Salet looks for every room having a tag in their tags array. The rooms are set by their IDs without any prefix. Example: choices = '#cabbage' Can be an array or a string. maxChoices If this property is set, it limits the length of the automatic list of choices in this room. Meaning, if maxChoices = 4, then this room's autolist won't have more than 4 choices. See also displayOrder and priority. tags An array of tags associated with this room, see choices. The tags are listed without additional modifiers, i.e. tag, not #tag. Example: tags = ['horror', 'answer', 'cabbage'] optionText A text for a choice in the autolist of choices. The text is parsed with Markdown and can be any HTML. If canChoose is true, it will be a link to this room. (if it's a function) Argument: current room's name dsc Room description. Printed every time on entering the room. extendSection The flag that controls if Salet should continue the previous section when the player enters this room. If set to false, the transition will be unmarked in the game's transcript. true by default. clear The flag that shows if Salet should clear the screen when entering this room. true by default. writers An object that keeps the link handlers for links like _writer_*, _replacer_*, _inserter_*. A link in the form of _writer_<id> calls a function writers.<id> and writes its output in the end of the transcript. A link in the form of _replacer_<id> calls a function writers.<id> and replaces a transcript text in the #<id> block with its output. A link in the form of _inserter_<id> calls a function writers.<id> and inserts its output to the end of the #<id> transcript block (not to the end of the all text). unitDelimiter A delimiter of unit descriptions. A single space by default. CoffeeScript methods canExit This function is called every time the player leaves the room. If it returns false, then it's forbidden to exit from this room, and so the player is instantly sent back. On this a move into other room ends and the player is forcibly moved into the old room from the new one. By default, returns true. Can be boolean value or a function. Argument: ID (name) of the room where the player is going to exit This function is called every time the player leaves the room. It's called after a new section is started, so if the new room has extendSection = true, then in the transcript any text that this function would write, visually will be in the new room. Salet won't automatically print any text this function returns; if you need a method that automatically prints its output, use before or after. Argument: ID (name) of the room where the player is going to enter This function is called every time the player enters the room. It's called every time a new section is opened, so in the transcript any text that this function would write, visually will be still in the old room. Salet won't automatically print any text this function returns; if you need a method that automatically prints its output, use before or after. Argument: ID (name) of the room where the player is going from entering A system function that handles entering the room. Argument 1: ID (name) of the room where the player is going from Argument 2: the force enter flag; if true, then canExit is not checked. false by default. take Moves a unit into this room Argument: unit, SaletUnit class drop Takes a unit out of this room. The unit is left without a location. Argument: unit name, a string corresponding to SaletUnit.name act A system function, a handler for all the links in this room (including unit links). Argument: link target. register A system function that registers this room in the Salet's list of rooms. link Links this room to a specified one, adding a link to the ways array. Argument: ID (name) of the room. bilink Links this room to a specified one and the specified one to this one, adding a bidirectional link. See the ways array. Argument: ID (name) of the room. api en/api/room.txt Last modified: 2021/01/24 10:42by 127.0.0.1