Core.aslx functions
Functions with very specific effects in the game world.
AddDescriptionLine
Section titled “AddDescriptionLine”AddDescriptionLine (string description so far, string line)Returns a string. Building-block used to assemble a multi-line description: if line is non-empty, any text already accumulated in description so far is printed immediately (via msg) and the description is reset to just line; if line is empty, description so far is returned unchanged. This lets you print each non-blank line as its own paragraph while collapsing blank lines, by repeatedly calling it and printing whatever’s left over at the end.
AddToInventory
Section titled “AddToInventory”AddToInventory (object)Moves the object to the inventory. This simply sets the object’s parent to the current player, so:
AddToInventory(myobject)is equivalent to
myobject.parent = game.povCanReachThrough
Section titled “CanReachThrough”CanReachThrough (object)Returns a boolean - true if the player can reach through the object.
CanSeeThrough
Section titled “CanSeeThrough”CanSeeThrough (object)Returns a boolean - true if the player can see through the object.
ChangePOV
Section titled “ChangePOV”ChangePOV (object)Switches the current player object (point of view) to the given object, which must already have a parent (e.g. be placed somewhere in the game world). Triggers OnEnterRoom for the new POV’s location. See Changing the player object for a full walkthrough.
CheckDarkness
Section titled “CheckDarkness”CheckDarkness()Returns a boolean - true if the player is in a room which is dark and has no strong lightsources in it. It also records the answer in the room’s darklevel attribute as it goes.
See also SetDark, SetLight, SetObjectLightstrength, SetExitLightstrength
CloneObjectAndInitialise
Section titled “CloneObjectAndInitialise”CloneObjectAndInitialise (object)Returns an object. Clones the object using CloneObject and, if the clone has an _initialise_ script, runs it. Useful for prototype objects that need to set up their own state (e.g. random stats) each time a new copy is created, rather than only when moved into a room - see also CloneObjectAndMoveHere.
FinishTurn
Section titled “FinishTurn”FinishTurn ()Ends the current turn: runs turn scripts (if game.runturnscripts is set and they haven’t been suppressed), then updates status attributes and darkness/hyperlink state for the next command. Quest Viva calls this automatically after each player command; you would only call it yourself if you’re driving a “turn” from custom code that bypasses the normal command loop.
FormatContentsList
Section titled “FormatContentsList”FormatContentsList (string pre-list, object parent, string pre-final, string post-list, boolean include scenery)Returns a string containing a formatted list of the direct children of parent. This is the shared implementation behind FormatObjectList (include scenery false) and FormatInventoryList (include scenery true) - call one of those instead unless you specifically need a third scenery-filtering behaviour.
FormatExitList
Section titled “FormatExitList”FormatExitList (string pre-list, objectlist exits, string pre-final, string post-list)Returns a string containing a formatted list of exits.
For example, this:
FormatExitList("You can go", ScopeExits(), "or", ", if you like.")may return output like this:
You can go east, west or south, if you like.
FormatInventoryList
Section titled “FormatInventoryList”FormatInventoryList (string pre-list, object parent, string pre-final, string post-list)Returns a string containing a formatted list of what parent is carrying, for the “inventory” command. Unlike FormatObjectList, scenery-flagged objects are always included: “scenery” means “don’t clutter the room description with this”, not “don’t tell the player they’re holding it”.
FormatObjectList
Section titled “FormatObjectList”FormatObjectList (string pre-list, object parent, string pre-final, string post-list)Returns a string containing a formatted list of objects.
Used by ShowRoomDescription to list what is in the room, and by the “look at” handling to list what is inside a container. The “inventory” command uses FormatInventoryList instead, because it needs scenery included.
FormatObjectList will display children of listed objects within brackets, if the parent object can be seen through.
For example, this:
FormatObjectList("You can see", player.parent, "and", "in this room.")may return output like this:
You can see a sofa, a lamp, a box (containing a diary and a pen) and a kitten in this room.
All object names will be hyperlinked to show a menu of verbs - displayverbs for objects in the room, or inventoryverbs for anything the player is carrying, chosen automatically by GetDisplayVerbs.
GetBlockingObject
Section titled “GetBlockingObject”GetBlockingObject (object)Returns the object which is preventing the player from reaching the specified object.
If an object is in ScopeVisible but not in ScopeReachable, then it may be inside a container where the player can see it but not reach it. You can call the GetBlockingObject function to find out what is “blocking” the player from reaching the object. It will be the top-most parent which the player cannot reach through.
GetClone
Section titled “GetClone”GetClone (object prototype, object parent)Returns the object among parent’s direct children whose prototype attribute points to prototype, or null if there isn’t one. parent is optional and defaults to the current player. Useful for finding a previously-made clone (see CloneObject) instead of creating a new one.
GetDefiniteName
Section titled “GetDefiniteName”GetDefiniteName (object)Returns a string containing the full displayed name of an object, prefixed with “the” if it is neither a named male or a named female.
GetDisplayAlias
Section titled “GetDisplayAlias”GetDisplayAlias (object)Returns a string containing the displayed version of the object name. This will be the alias, if the object has one, otherwise it will just be the object name.
GetDisplayName
Section titled “GetDisplayName”GetDisplayName (object)Returns a string containing the full displayed name of an object.
This will be the prefix + the result from GetDisplayAlias + the suffix.
GetDisplayNameLink
Section titled “GetDisplayNameLink”For Quest 5.3 and earlier:
GetDisplayNameLink (object, string type, stringlist verbs)For Quest 5.4 and later, there is no verbs parameter:
GetDisplayNameLink (object, string type)Returns a string containing the full displayed name of an object.
This will be the prefix + the result from GetDisplayAlias + the suffix.
If type is not an empty string (and, in Quest 5.3 and earlier, a verbs list is specified), the result will include the display alias wrapped in an <object> tag complete with verbs. This will mean the Quest Viva interface will display a hyperlinked object name with a menu of verbs. In Quest 5.4 and later, the displayverbs or inventoryverbs are picked up automatically depending on the object’s parent.
GetDisplayVerbs
Section titled “GetDisplayVerbs”GetDisplayVerbs (object)Returns a stringlist with the current display verbs for the object. If the object is in the current player’s inventory, the inventoryverbs are used as a base, otherwise the displayverbs are used. If autodisplayverbs is turned on, any verbs set up for the object will be added to the list returned.
GetListDisplayAlias
Section titled “GetListDisplayAlias”GetListDisplayAlias (object)Returns a string containing the displayed version of the object name to use in the object panes. This will be the listalias, if the object has one, otherwise it will be the result of GetDisplayAlias.
GetNonTransparentParent
Section titled “GetNonTransparentParent”GetNonTransparentParent (object)Returns the first object in the parent hierarchy that is non-transparent. If the object specified in the parameter is the player, then it is the limit of what the player can see out of - usually the object that represents the current room.
So if the player gets onto a platform within a room, or is inside a transparent box within the room, you can still find out the overall parent room by calling this function.
GetRoomDescription
Section titled “GetRoomDescription”GetRoomDescription ()Returns a string containing the full formatted description of the current room (the current player’s parent) - the same text ShowRoomDescription would print, including the dark-room fallback from CheckDarkness. Useful if you want the description as text rather than having it printed immediately, e.g. to include it in a menu or a saved log.
GetVolume
Section titled “GetVolume”GetVolume (object, boolean inclusiveobject)Returns the volume of an object with all its children.
If inclusiveobject is false, then the volume of all objects within object is returned without the volume of object itself.
If inclusiveobject is true, then the volume of all objects within object is returned inclusive the volume of object itself.
Got (object)Returns a boolean - true if the player has the specified object. This is just a convenient shortcut to seeing if it is within the list returned by ScopeInventory.
GridSquareClick
Section titled “GridSquareClick”GridSquareClick (integer x, integer y)Override hook for grid maps: the default implementation does nothing. Copy this function into your game and give it a body to handle clicks on a grid map square, using the clicked square’s coordinates.
HelperCloseObject
Section titled “HelperCloseObject”HelperCloseObject (object)Closes the object. This simply sets the isopen attribute to false.
See also HelperOpenObject
HelperOpenObject
Section titled “HelperOpenObject”HelperOpenObject (object)Opens the object. This simply sets the isopen attribute to true.
See also HelperCloseObject
IsSwitchedOn
Section titled “IsSwitchedOn”IsSwitchedOn (object)Returns a boolean - true if the object is switched on.
This function simply reads the switchedon attribute of the object.
ListParents
Section titled “ListParents”ListParents (object)Returns an objectlist of all parents of an object - the object’s direct parent, the parent’s parent, and so on.
MoveObjectHere
Section titled “MoveObjectHere”MoveObjectHere (object)Moves the object to the current player’s room. Equivalent to object.parent = game.pov.parent. See also MoveObject to move an object to an arbitrary parent, and AddToInventory to move it into the player’s inventory instead.
SetDark
Section titled “SetDark”SetDark(room)Set a room to dark. Objects and Exits can’t be seen unless there is a lightsource object in this room.
See also SetLight, SetObjectLightstrength,SetExitLightstrength, CheckDarkness
SetExitLightstrength
Section titled “SetExitLightstrength”SetExitLightstrength(exit, string value)Define an exit as a lightsource. A possible value is:
“” (empty string) : exit is not a lightsource and is not visible in a dark room
“weak” : exit is visible in a dark room
“strong” : exit enlightens a dark room, so the normal room description is shown
See also SetDark, SetLight, SetObjectLightstrength, CheckDarkness
SetLight
Section titled “SetLight”SetLight(room)Set a room to light.
See also SetDark, SetObjectLightstrength, SetExitLightstrength, CheckDarkness
SetObjectLightstrength
Section titled “SetObjectLightstrength”SetObjectLightstrength(object, string value)Define an object as a lightsource. A possible value is:
“” (empty string) : object is not a lightsource and is not visible in a dark room
“weak” : object is visible in a dark room
“strong” : object enlightens a dark room, so the normal room description is shown
See also SetDark, SetLight, SetExitLightstrength, CheckDarkness
ShowRoomDescription
Section titled “ShowRoomDescription”Internal function to Core.aslx - games should not normally need to call internal functions.
ShowRoomDescription ()Does not return a value.
SwitchOff
Section titled “SwitchOff”SwitchOff (object)Switches off the specified object, simply by setting the switchedon property to false.
SwitchOn
Section titled “SwitchOn”SwitchOn (object)Switches on the specified object, simply by setting the switchedon property to true.
WhereAmI
Section titled “WhereAmI”WhereAmI (string platform name)Sets the questplatform attribute on game to the given string. Despite the name, this has nothing to do with the player’s location - nothing in the current engine reads questplatform back, so this is a legacy hook rather than something new games need to call.