CorsixTH Lua Documentation

World Class

Manages entities, rooms, and the date.

Declared on: line 34 of Lua/world.lua.

Method Index

Member Index

function World:World(app)

Parameters:

NameTypeDescription
app ? ?

Declared on: line 47 of Lua/world.lua.

function World:addObjectToTile(object, x, y)

Notify the world of a new object being placed somewhere in the world

See also `World:removeObjectFromTile`

Parameters:

NameTypeDescription
object Object The object being placed
x integer The X-coordinate of the tile being placed upon
y integer The Y-coordinate of the tile being placed upon

Declared on: line 1920 of Lua/world.lua.

function World:adjustZoom(delta)

Parameters:

NameTypeDescription
delta ? ?

Declared on: line 190 of Lua/world.lua.

function World:afterLoad(old, new)

Let the world react to and old save game. First it gets the chance to do things for itself, and then it calls corresponding functions for the hospitals, entities and rooms in that order.

Parameters:

NameTypeDescription
old ? The old version of the save game.
new ? The current version of the save game format.

Declared on: line 2065 of Lua/world.lua.

function World:calculateSpawnTiles()

Identify the tiles on the map suitable for spawning `Humanoid`s from.

Declared on: line 446 of Lua/world.lua.

function World:checkWinningConditions(player_no)

(reputation, balance, percentage_killed) and a number limit which

corresponds to the limit the player passed.

Parameters:

NameTypeDescription
player_no ? The index of the player to check in the world's list of hospitals

Declared on: line 1390 of Lua/world.lua.

function World:clearCaches()

Clear all internal caches which are dependant upon map state / object position

Declared on: line 848 of Lua/world.lua.

function World:createMapObjects(objects)

Parameters:

NameTypeDescription
objects ? ?

Declared on: line 746 of Lua/world.lua.

function World:debugDisableSalaryRaise(mode)

Parameters:

NameTypeDescription
mode ? ?

Declared on: line 692 of Lua/world.lua.

function World:destroyEntity(entity)

Parameters:

NameTypeDescription
entity ? ?

Declared on: line 1820 of Lua/world.lua.

function World:determineWinningConditions()

Load goals to win and lose from the map, and store them in 'self.goals'.

Also set 'self.winning_goal_count'.

Declared on: line 298 of Lua/world.lua.

function World:dumpGameLog()

Dump the contents of the game log into a file. This is automatically done on each error.

Declared on: line 2039 of Lua/world.lua.

function World:findAllObjectsNear(x, y, distance, object_type_name)

Returns a set of all objects near the given position but if supplied only of the given object type.

Parameters:

NameTypeDescription
x ? The x-coordinate at which to originate the search
y ? The y-coordinate
distance ? The number of tiles away from the origin to search
object_type_name ? The name of the objects that are being searched for

Declared on: line 1620 of Lua/world.lua.

function World:findFreeObjectNearToUse(humanoid, object_type_name, which, current_object)

Parameters:

NameTypeDescription
humanoid ? ?
object_type_name ? ?
which ? ?
current_object ? ?

Declared on: line 1713 of Lua/world.lua.

function World:findObjectNear(humanoid, object_type_name, distance, callback)

Find all objects of the given type near the humanoid. Note that regardless of distance, only the room which the humanoid is in is searched (or the corridor if the humanoid is not in a room). When no callback is specified then the first object found is returned, along with its usage tile position. This may return an object already being used - if you want to find an object not in use (in order to use it), then call findFreeObjectNearToUse instead.

Parameters:

NameTypeDescription
humanoid ? The humanoid to search around
object_type_name ? The objects to search for
distance ? Maximum L1 distance to search from humanoid. If nil then everywhere in range will be searched.
callback ? Function to call for each result. If it returns true then the search will be ended. --

Declared on: line 1651 of Lua/world.lua.

function World:findRoomNear(humanoid, room_type_id, distance, mode)

Parameters:

NameTypeDescription
humanoid ? ?
room_type_id ? ?
distance ? ?
mode ? ?

Declared on: line 1753 of Lua/world.lua.

function World:gameLog(message)

Append a message to the game log.

Parameters:

NameTypeDescription
message string The message to add.

Declared on: line 2029 of Lua/world.lua.

function World:getAnimLength(anim)

Parameters:

NameTypeDescription
anim ? ?

Declared on: line 784 of Lua/world.lua.

function World:getCurrentMonthLength()

Return the length of the current month

Declared on: line 909 of Lua/world.lua.

function World:getCurrentSpeed()

Return the name of the current speed, relating to a key in tick_rates.

Declared on: line 930 of Lua/world.lua.

function World:getFreeBench(x, y, distance)

Parameters:

NameTypeDescription
x ? ?
y ? ?
distance ? ?

Declared on: line 1589 of Lua/world.lua.

function World:getIdleTile(x, y, idx)

Parameters:

NameTypeDescription
x ? ?
y ? ?
idx ? ?

Declared on: line 1561 of Lua/world.lua.

function World:getObject(x, y, id)

Parameters:

NameTypeDescription
x ? ?
y ? ?
id ? ?

Declared on: line 1948 of Lua/world.lua.

function World:getObjectToNotifyOfOccupants(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 740 of Lua/world.lua.

function World:getObjects(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 1943 of Lua/world.lua.

function World:getObjectsById(id)

Parameters:

NameTypeDescription
id ? ?

Declared on: line 1970 of Lua/world.lua.

function World:getPath(x, y, dest_x, dest_y)

Parameters:

NameTypeDescription
x ? ?
y ? ?
dest_x ? ?
dest_y ? ?

Declared on: line 1557 of Lua/world.lua.

function World:getPathDistance(x1, y1, x2, y2)

Calculate the distance of the shortest path (along passable tiles) between the two given map tiles. This operation is commutative (swapping (x1, y1) with (x2, y2) has no effect on the result) if both tiles are passable.

Parameters:

NameTypeDescription
x1 integer X-cordinate of first tile's Lua tile co-ordinates.
y1 integer Y-cordinate of first tile's Lua tile co-ordinates.
x2 integer X-cordinate of second tile's Lua tile co-ordinates.
y2 integer Y-cordinate of second tile's Lua tile co-ordinates.

Declared on: line 1544 of Lua/world.lua.

function World:getRoom(x, y)

Parameters:

NameTypeDescription
x ? ?
y ? ?

Declared on: line 1997 of Lua/world.lua.

function World:getRoomNameAndRequiredStaffName(room_id)

Returns localized name of the room, internal required staff name and localized name of staff required.

Parameters:

NameTypeDescription
room_id ? ?

Declared on: line 2001 of Lua/world.lua.

function World:getWallDirFromBlockId(block_id)

Parameters:

NameTypeDescription
block_id ? ?

Declared on: line 869 of Lua/world.lua.

function World:getWallIdFromBlockId(block_id)

Parameters:

NameTypeDescription
block_id ? ?

Declared on: line 853 of Lua/world.lua.

function World:getWallSetFromBlockId(block_id)

Parameters:

NameTypeDescription
block_id ? ?

Declared on: line 861 of Lua/world.lua.

function World:initFromPreviousLevel(carry)

Initializes variables carried from previous levels

Parameters:

NameTypeDescription
carry ? ?

Declared on: line 425 of Lua/world.lua.

function World:initLevel(app)

Parameters:

NameTypeDescription
app ? ?

Declared on: line 210 of Lua/world.lua.

function World:isCurrentSpeed(speed)

Return if the selected speed the same as the current speed.

Parameters:

NameTypeDescription
speed ? ?

Declared on: line 924 of Lua/world.lua.

function World:isTilePartOfNearbyObject(x, y, distance)

This helper function checks if the given tile is part of a nearby object (walkable tiles count as part of the object)

Parameters:

NameTypeDescription
x ? ?
y ? ?
distance ? ?

Declared on: line 1608 of Lua/world.lua.

function World:loseGame(player_no, reason, limit)

Cause the player with the player number player_no to lose.

Parameters:

NameTypeDescription
player_no number The number of the player which should lose.
reason string [optional] The name of the criterion the player lost to.
limit number [optional] The number the player went over/under which caused him to lose.

Declared on: line 1508 of Lua/world.lua.

function World:makeAvailableStaff(month)

Parameters:

NameTypeDescription
month ? ?

Declared on: line 702 of Lua/world.lua.

function World:markRoomAsBuilt(room)

Called when a room has been completely built and is ready to use

Parameters:

NameTypeDescription
room ? ?

Declared on: line 828 of Lua/world.lua.

function World:newEntity(class, animation)

Parameters:

NameTypeDescription
class ? ?
animation ? ?

Declared on: line 1811 of Lua/world.lua.

function World:newFloatingDollarSign(patient, amount)

Setup an animated floating money amount above a patient.

Parameters:

NameTypeDescription
patient ? Patient to float above.
amount ? Amount of money to display.

Declared on: line 1784 of Lua/world.lua.

function World:newObject(id, ...)

Creates a new object by finding the object_type from the "id" variable and calls its class constructor.

Parameters:

NameTypeDescription
id string The unique id of the object to be created.
... ? ?

Declared on: line 1830 of Lua/world.lua.

function World:newRoom(x, y, w, h, room_info, ...)

Parameters:

NameTypeDescription
x ? ?
y ? ?
w ? ?
h ? ?
room_info ? ?
... ? ?

Declared on: line 814 of Lua/world.lua.

function World:nextEarthquake()

Called when it is time to have another earthquake

Declared on: line 1346 of Lua/world.lua.

function World:nextEmergency()

Called when it is time to determine what the next emergency should look like.

Declared on: line 1260 of Lua/world.lua.

function World:nextVip()

Called when it is time to have another VIP

Declared on: line 1322 of Lua/world.lua.

function World:notifyObjectOfOccupants(x, y, object)

Register a callback for when `Humanoid`s enter or leave a given tile.

Note that only one callback may be registered to each tile.

Parameters:

NameTypeDescription
x integer The 1-based X co-ordinate of the tile to monitor.
y integer The 1-based Y co-ordinate of the tile to monitor.
object Object Something with an `onOccupantChange` method, which will be called whenever a `Humanoid` enters or leaves the given tile. The method will recieve one argument (after `self`), which will be `1` for an enter event and `-1` for a leave event.

Declared on: line 726 of Lua/world.lua.

function World:notifyRoomRemoved(room)

Called when a room has been deactivated (crashed or edited)

Parameters:

NameTypeDescription
room ? ?

Declared on: line 840 of Lua/world.lua.

function World:objectPlaced(entity, id)

Notifies the world that an object has been placed, notifying interested entities in the vicinity of the new arrival.

Parameters:

NameTypeDescription
entity Entity The entity that was just placed.
id string That entity's id.

Declared on: line 1852 of Lua/world.lua.

function World:onEndDay()

Called immediately prior to the ingame day changing.

Declared on: line 1109 of Lua/world.lua.

function World:onEndMonth()

Called immediately prior to the ingame month changing. returns true if the game was killed due to the player losing

Declared on: line 1196 of Lua/world.lua.

function World:onEndYear()

Called immediately prior to the ingame year changing.

Declared on: line 1526 of Lua/world.lua.

function World:onTick()

World ticks are translated to game ticks (or hours) depending on the current speed of the game. There are 50 hours in a TH day.

Declared on: line 990 of Lua/world.lua.

function World:pauseOrUnpause()

Dedicated function to allow unpausing by pressing 'p' again

Declared on: line 964 of Lua/world.lua.

function World:registerRoomBuildCallback(callback)

Register a function to be called whenever a room is built.

Parameters:

NameTypeDescription
callback function A function taking one argument: a `Room`.

Declared on: line 788 of Lua/world.lua.

function World:registerRoomRemoveCallback(callback)

Register a function to be called whenever a room has been deactivated (crashed or edited).

Parameters:

NameTypeDescription
callback function A function taking one argument: a `Room`.

Declared on: line 801 of Lua/world.lua.

function World:removeObjectFromTile(object, x, y)

Notify the world of an object being removed from a tile

See also `World:addObjectToTile`

Parameters:

NameTypeDescription
object Object The object being removed.
x integer The X-coordinate of the tile which the object was on
y integer The Y-coordinate of the tile which the object was on

Declared on: line 1895 of Lua/world.lua.

function World:resetAnimations()

Because the save file only saves one thob per tile if they are more that information will be lost. To solve this after a load we need to set again all the thobs on each tile.

Declared on: line 2057 of Lua/world.lua.

function World:resetSideObjects()

There is a problem with room editing in that it resets all the partial passable flags (travelNorth, travelSouth etc.) in the corridor, a workaround is calling this function after the room was edited so that all edge only objects, that set partial passable flags set those flags again

Declared on: line 2319 of Lua/world.lua.

function World:setPlotOwner(parcel, owner)

Parameters:

NameTypeDescription
parcel ? ?
owner ? ?

Declared on: line 771 of Lua/world.lua.

function World:setSpeed(speed)

Set the (approximate) number of seconds per tick.

Parameters:

NameTypeDescription
speed string One of: "Pause", "Slowest", "Slower", "Normal", "Max speed", or "And then some more".

Declared on: line 939 of Lua/world.lua.

function World:setUI(ui)

Register key shortcuts for controling the world (game speed, etc.)

Parameters:

NameTypeDescription
ui ? ?

Declared on: line 174 of Lua/world.lua.

function World:spawnPatient(hospital)

Parameters:

NameTypeDescription
hospital ? ?

Declared on: line 478 of Lua/world.lua.

function World:spawnVIP(name)

Parameters:

NameTypeDescription
name ? ?

Declared on: line 532 of Lua/world.lua.

function World:unregisterRoomBuildCallback(callback)

Unregister a function from being called whenever a room is built.

Parameters:

NameTypeDescription
callback function A function previously passed to `registerRoomBuildCallback`.

Declared on: line 794 of Lua/world.lua.

function World:unregisterRoomRemoveCallback(callback)

Unregister a function from being called whenever a room has been deactivated (crashed or edited).

Parameters:

NameTypeDescription
callback function A function previously passed to `registerRoomRemoveCallback`.

Declared on: line 807 of Lua/world.lua.

function World:updateSpawnDates()

Called when a month ends. Decides on which dates patients arrive during the coming month.

Declared on: line 1245 of Lua/world.lua.

function World:winGame(player_no)

Parameters:

NameTypeDescription
player_no ? ?

Declared on: line 1443 of Lua/world.lua.

Page generated on Sat Feb 07, 2015 at 18:38:28 by LDocGen.