World Class
Manages entities, rooms, and the date.
Method Index
- _createMapObject(object)
- _executeAutosave()
- _findClosestSpawnToDesk(staffed_desks, spawns)
- _flushDestroyedEntities()
- _generateNextVipDate()
- _prepareSpawnDates(first_game_month)
- _prepareSpawnHours()
- addObjectToTile(object, x, y)
- adjustZoom(delta)
- afterLoad(old, new)
- anyHumanoidObscuringArea(x, y)
- applyLevelStartPrices()
- atLeastOneHumanoidLocatedAtTile(x, y)
- atLeastOneObjectLocatedAtTile(x, y)
- calculateSpawnTiles()
- canNonSideObjectBeSpawnedAt(x, y, objects_id, orientation, spawn_rooms_id, player_id)
- checkIfGameWon()
- chooseHospitalForPatient(disease)
- clearCaches()
- computeNextEmergencyDates(emergency)
- createMapObjects(objects)
- date()
- debugDisableSalaryRaise(mode)
- destroyEntity(entity)
- determineWinningConditions()
- dumpGameLog()
- findAllObjectsNear(x, y, distance, object_type_name)
- findFreeObjectNearToUse(humanoid, object_type_name, which, current_object)
- findObjectNear(humanoid, object_type_name, distance, only_usable, callback)
- findRoomNear(humanoid, room_type_id, max_distance, mode)
- gameLog(message)
- getAvailableRooms()
- getCampaignData()
- getCampaignWinningText(player_no)
- getCurrentSpeed()
- getFreeBench(x, y, distance)
- getHospital(x, y)
- getIdleTile(x, y, idx, parcel_id)
- getLocalPlayerHospital()
- getNewPatientDisease()
- getObject(x, y, id, only_usable)
- getObjectToNotifyOfOccupants(x, y)
- getObjects(x, y)
- getPath(x, y, dest_x, dest_y)
- getPathDistance(x1, y1, x2, y2)
- getPlayerMachines()
- getRoom(x, y)
- getRoomNameAndRequiredStaffName(room_id)
- getWallDirFromBlockId(block_id)
- getWallIdFromBlockId(block_id)
- getWallSetFromBlockId(block_id)
- initLevel(app, avail_rooms)
- initWallTypes()
- isCampaign()
- isCurrentSpeed(speed)
- isFootprintTileBuildableOrPassable(x, y, tile, footprint, requirement_flag, player_id)
- isGameUserPaused()
- isMustPauseActive()
- isNearRat(x, y)
- isOnMap(x, y)
- isPaused()
- isTileEmpty(x, y, not_in_room)
- isTileExclusivelyPassable(x, y, distance)
- isTilePartOfNearbyObject(x, y, distance)
- isUserActionProhibited()
- localiseInitial(profile)
- loseGame(player_no, reason, limit)
- makeAvailableStaff(month)
- markRoomAsBuilt(room)
- mustPauseWindowAdd()
- mustPauseWindowRemoved()
- newEntity(class, animation, mood_marker)
- newFloatingDollarSign(patient, amount)
- newLitter(litter_type, x, y, mirror)
- newObject(id, x, y, flags, name)
- newObjectType(new_object)
- newRoom(x, y, w, h, room_info, ...)
- nextEmergency()
- nextVip()
- notifyObjectOfOccupants(x, y, object)
- notifyRoomRemoved(room)
- objectPlaced(entity, id)
- onEndDay()
- onEndMonth()
- onEndYear()
- onTick()
- pauseOrUnpause()
- playLoadedEntitySounds()
- prepareFootprintTilesForBuild(object_footprint, x, y)
- prepareRectangleTilesForBuild(x, y, w, h)
- previousSpeed()
- registerRoomRemoveCallback(callback)
- removeAllLitter(x, y)
- removeObjectFromTile(object, x, y)
- resetAnimations()
- resetSideObjects()
- resetZoom()
- scheduleRandomEmergency(control)
- setCampaignData(campaign_data)
- setEndMonth()
- setEndYear()
- setPlotOwner(parcel, owner)
- setSpeed(new_speed)
- setUI(ui)
- setUserPaused(state)
- setUserSpeed(new_speed)
- spawnPatient(hospital)
- spawnVIP(name)
- speedUp()
- toggleInformation()
- unregisterRoomRemoveCallback(callback)
- updateInitialsCache()
- updateScreenBlueFilter()
- updateUserActionsAllowed()
- updateUserInteractionState()
- validateMap()
- wasEmergencySkipped(prev_date, new_date)
- willObjectsFootprintTileBeWithinItsAllowedRoomIfLocatedAt(x, y, object, allowed_rooms_id_parameter)
- winGame(player_no)
- wouldNonSideObjectBreakPathfindingIfSpawnedAt(x, y, object, objects_orientation, room_id)
- wouldNonSideObjectsNotHaveAccessToRoomDoor(object_x, object_y, room, object_layout)
- wouldObjectBreakRoomObjectsAccessToTheRoomDoor(object_x, object_y, room, object_layout, is_side_object)
Member Index
- anim_length_cache
- animation_manager
- anims
- app
- autosave_next_tick
- available_diseases
- available_rooms
- available_staff
- campaign_info
- cheat_announcements
- current_tick_entity
- day
- debug_disable_salary_raise
- delayed_map_objects
- dispatcher
- earthquake
- endconditions
- entities
- entities_to_destroy
- entity_map
- floating_dollars
- free_build_mode
- game_date
- game_log
- goals
- hospitals
- hour
- hours_per_day
- hours_per_tick
- idle_cache
- level_criteria
- map
- month
- monthly_spawn_increase
- next_emergency
- next_emergency_date
- next_emergency_day
- next_emergency_month
- next_emergency_no
- next_vip_date
- next_vip_day
- next_vip_month
- object_counts
- object_id_by_thob
- object_types
- objects
- objects_notify_occupants
- original_savegame_version
- pathfinder
- prev_speed
- release_version
- room_build_callbacks
- room_built
- room_information_dialogs
- room_remove_callbacks
- rooms
- savegame_version
- spawn_dates
- spawn_hours
- spawn_points
- spawn_rate
- system_pause
- tick_rate
- tick_timer
- ui
- user_actions_allowed
- user_paused
- wall_dir_by_block_id
- wall_id_by_block_id
- wall_set_by_block_id
- wall_types
- year
function World:World(app, free_build_mode)
Parameters:
| Name | Type | Description |
|---|---|---|
| app | ? | ? |
| free_build_mode | ? | ? |
Declared on: line 54 of Lua/world.lua.
function World:_createMapObject(object)
Internal function for placing an object from the map file.
Parameters:
| Name | Type | Description |
|---|---|---|
| object | ? | Object to place. |
Declared on: line 567 of Lua/world.lua.
function World:_executeAutosave()
Creates a save file in the "Autosaves" folder, using the "Autosave-mm-dd.sav" name template for filename.
If the "Autosaves" folder does not exist, folder will be created.
Declared on: line 1000 of Lua/world.lua.
function World:_findClosestSpawnToDesk(staffed_desks, spawns)
Private function to assess the shortest path between all spawn points and desks
Parameters:
| Name | Type | Description |
|---|---|---|
| staffed_desks | table | All staffed reception desks |
| spawns | table | All available spawn points |
Declared on: line 397 of Lua/world.lua.
function World:_flushDestroyedEntities()
Entities are queued by World:destroyEntity while iterating over
self.entities, so this must only be called once that iteration finished.
Declared on: line 1858 of Lua/world.lua.
function World:_generateNextVipDate()
PRIVATE method to generate the next VIP date
Note: it is important we ensure this date always is in the future
Declared on: line 1319 of Lua/world.lua.
function World:_prepareSpawnDates(first_game_month)
Called when a month ends. Decides on which dates patients arrive
during the coming month.
Parameters:
| Name | Type | Description |
|---|---|---|
| first_game_month | bool | Is that the very first date distribution at the level TODO: Requires adjustment for AIHospital spawns; see PR 1986 for progress. |
Declared on: line 1177 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:
| Name | Type | Description |
|---|---|---|
| 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 2290 of Lua/world.lua.
function World:adjustZoom(delta)
Adjust the current zoom level by a delta
TODO: This should live in game_ui not world
Parameters:
| Name | Type | Description |
|---|---|---|
| delta | ? | ? |
Declared on: line 188 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:
| Name | Type | Description |
|---|---|---|
| old | integer | The old version of the save game. |
| new | integer | The current version of the save game format. |
Declared on: line 2547 of Lua/world.lua.
function World:anyHumanoidObscuringArea(x, y)
Сhecks whether a tile is occupied by any humanoid.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | integer | the queried tile's x coordinate. |
| y | integer | the queried tile's y coordinate. |
Declared on: line 1559 of Lua/world.lua.
function World:applyLevelStartPrices()
Apply level-defined pricing to all available diseases.
Declared on: line 264 of Lua/world.lua.
function World:atLeastOneHumanoidLocatedAtTile(x, y)
Checks if any humanoid is located on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | integer | the queried tile's x coordinate. |
| y | integer | the queried tile's y coordinate. |
Declared on: line 1551 of Lua/world.lua.
function World:atLeastOneObjectLocatedAtTile(x, y)
Checks if any object is located on a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | integer | the queried tile's x coordinate. |
| y | integer | the queried tile's y coordinate. |
Declared on: line 1543 of Lua/world.lua.
function World:calculateSpawnTiles()
Identify the tiles on the map suitable for spawning `Humanoid`s from.
Declared on: line 331 of Lua/world.lua.
function World:canNonSideObjectBeSpawnedAt(x, y, objects_id, orientation, spawn_rooms_id, player_id)
Checks whether object can be spawned at some coordinates.
For example, when searching for a suitable placement for "gates_to_hell".
'NonSideObject' is a object that do occupy the tile entirely, not only one side of it.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| objects_id | ? | ? |
| orientation | ? | ? |
| spawn_rooms_id | ? | ? |
| player_id | ? | ? |
Declared on: line 1909 of Lua/world.lua.
function World:checkIfGameWon()
Declared on: line 1141 of Lua/world.lua.
function World:chooseHospitalForPatient(disease)
Choose hospital for normal patient
Parameters:
| Name | Type | Description |
|---|---|---|
| disease | table | - the disease assigned to this patient |
Declared on: line 3112 of Lua/world.lua.
function World:clearCaches()
Clear all internal caches which are dependent upon map state / object position
Declared on: line 662 of Lua/world.lua.
function World:computeNextEmergencyDates(emergency)
Generate the dates for the next emergency
Parameters:
| Name | Type | Description |
|---|---|---|
| emergency | ? | The next scheduled emergency to take place |
Declared on: line 1292 of Lua/world.lua.
function World:createMapObjects(objects)
Place objects from a map file onto the map.
Parameters:
| Name | Type | Description |
|---|---|---|
| objects | ? | Objects to place. |
Declared on: line 556 of Lua/world.lua.
function World:date()
Get todays date.
Declared on: line 3052 of Lua/world.lua.
function World:debugDisableSalaryRaise(mode)
Enable or disable salary raise events.
Parameters:
| Name | Type | Description |
|---|---|---|
| mode | boolean | If true, do not create salary raise events. |
Declared on: line 501 of Lua/world.lua.
function World:destroyEntity(entity)
Parameters:
| Name | Type | Description |
|---|---|---|
| entity | ? | ? |
Declared on: line 1835 of Lua/world.lua.
function World:determineWinningConditions()
In EndConditions, collect and test the win and lose conditions of the level.
Declared on: line 281 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 2482 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:
| Name | Type | Description |
|---|---|---|
| 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 1611 of Lua/world.lua.
function World:findFreeObjectNearToUse(humanoid, object_type_name, which, current_object)
Parameters:
| Name | Type | Description |
|---|---|---|
| humanoid | ? | ? |
| object_type_name | ? | ? |
| which | ? | ? |
| current_object | ? | ? |
Declared on: line 1707 of Lua/world.lua.
function World:findObjectNear(humanoid, object_type_name, distance, only_usable, 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:
| Name | Type | Description |
|---|---|---|
| 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. |
| only_usable | ? | Bool If true the object must be permitted for use |
| callback | ? | Function to call for each result. If it returns true then the search will be ended. -- |
Declared on: line 1642 of Lua/world.lua.
function World:findRoomNear(humanoid, room_type_id, max_distance, mode)
Finds the most desirable room of a given room type for the provided humanoid.
"advanced" prefers a near room but also takes into account queue size/staffing
Parameters:
| Name | Type | Description |
|---|---|---|
| humanoid | ? | The queried NPC (start point) |
| room_type_id | string | The room we are looking for |
| max_distance | number | The maximum distance away a room will be considered from the humanoid |
| mode | string | "nearest"/nil returns the nearest room, while |
Declared on: line 1747 of Lua/world.lua.
function World:gameLog(message)
Append a message to the game log.
Parameters:
| Name | Type | Description |
|---|---|---|
| message | string | The message to add. |
Declared on: line 2472 of Lua/world.lua.
function World:getAvailableRooms()
Find the rooms available at the level.
Declared on: line 287 of Lua/world.lua.
function World:getCampaignData()
Collect the settings that should be reused in the next world
Declared on: line 3058 of Lua/world.lua.
function World:getCampaignWinningText(player_no)
the "continue"-choice the player has, and whether it is the "return_to_main_menu"
choice or the "accept_new_level" choice.
Parameters:
| Name | Type | Description |
|---|---|---|
| player_no | integer | Which player that will see the message. |
Declared on: line 1374 of Lua/world.lua.
function World:getCurrentSpeed()
Return the name of the current speed, relating to a key in tick_rates.
Declared on: line 748 of Lua/world.lua.
function World:getFreeBench(x, y, distance)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| distance | ? | ? |
Declared on: line 1574 of Lua/world.lua.
function World:getHospital(x, y)
Get the hospital at a given tile location.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the queried tile. |
| y | int | Y position of the queried tile. |
Declared on: line 2424 of Lua/world.lua.
function World:getIdleTile(x, y, idx, parcel_id)
Find an tile for idling.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | X coordinate of the queue position. |
| y | ? | Y coordinate of the queue position. |
| idx | ? | Randomization factor for the idle tile, returns Nth candidate tile. |
| parcel_id | ? | Optional parcel of the indoor returned idling tile. |
Declared on: line 1497 of Lua/world.lua.
function World:getLocalPlayerHospital()
Get the hospital controlled by the (single) player.
Declared on: line 323 of Lua/world.lua.
function World:getNewPatientDisease()
Find a valid disease that a patient can use
Declared on: line 3090 of Lua/world.lua.
function World:getObject(x, y, id, only_usable)
Retrieve one object from a given position.
that id, set of strings gets first object that matches an entry in the set.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the object to retrieve. |
| y | int | Y position of the object to retrieve. |
| id | ? | Id to search, nil gets first object, string gets first object with |
| only_usable | bool | If true the object must be permitted for use |
Declared on: line 2318 of Lua/world.lua.
function World:getObjectToNotifyOfOccupants(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
Declared on: line 551 of Lua/world.lua.
function World:getObjects(x, y)
Retrieve all objects from a given position.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the object to retrieve. |
| y | int | Y position of the object to retrieve. |
Declared on: line 2310 of Lua/world.lua.
function World:getPath(x, y, dest_x, dest_y)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| dest_x | ? | ? |
| dest_y | ? | ? |
Declared on: line 1493 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:
| Name | Type | Description |
|---|---|---|
| x1 | integer | X-cordinate of first tile's Lua tile coordinates. |
| y1 | integer | Y-cordinate of first tile's Lua tile coordinates. |
| x2 | integer | X-cordinate of second tile's Lua tile coordinates. |
| y2 | integer | Y-cordinate of second tile's Lua tile coordinates. |
Declared on: line 1480 of Lua/world.lua.
function World:getPlayerMachines()
Gets a list of all the machines in the player's hospital.
Declared on: line 2454 of Lua/world.lua.
function World:getRoom(x, y)
Get the room at a given tile location.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the queried tile. |
| y | int | Y position of the queried tile. |
Declared on: line 2416 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:
| Name | Type | Description |
|---|---|---|
| room_id | ? | ? |
Declared on: line 2436 of Lua/world.lua.
function World:getWallDirFromBlockId(block_id)
Parameters:
| Name | Type | Description |
|---|---|---|
| block_id | ? | ? |
Declared on: line 710 of Lua/world.lua.
function World:getWallIdFromBlockId(block_id)
Parameters:
| Name | Type | Description |
|---|---|---|
| block_id | ? | ? |
Declared on: line 694 of Lua/world.lua.
function World:getWallSetFromBlockId(block_id)
Parameters:
| Name | Type | Description |
|---|---|---|
| block_id | ? | ? |
Declared on: line 702 of Lua/world.lua.
function World:initLevel(app, avail_rooms)
Initialize the game level (available diseases, winning conditions).
Parameters:
| Name | Type | Description |
|---|---|---|
| app | ? | Game application. |
| avail_rooms | list | Available rooms in the level. |
Declared on: line 214 of Lua/world.lua.
function World:initWallTypes()
Declared on: line 667 of Lua/world.lua.
function World:isCampaign()
Returns whether the level being played is part of a campaign or not
Declared on: line 3159 of Lua/world.lua.
function World:isCurrentSpeed(speed)
Return true if the given speed the same as the current speed.
Parameters:
| Name | Type | Description |
|---|---|---|
| speed | ? | ? |
Declared on: line 742 of Lua/world.lua.
function World:isFootprintTileBuildableOrPassable(x, y, tile, footprint, requirement_flag, player_id)
-
A footprint tile will either need to be buildable or passable so this function
checks if its buildable/passable using the tile's appropriate flag and then returns this
flag's boolean value or false if the tile isn't valid.
-
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| tile | ? | ? |
| footprint | ? | ? |
| requirement_flag | ? | ? |
| player_id | ? | ? |
Declared on: line 1967 of Lua/world.lua.
function World:isGameUserPaused()
Check whether user pause state applies
Declared on: line 851 of Lua/world.lua.
function World:isMustPauseActive()
Check if "Must Pause" mode enabled
Declared on: line 833 of Lua/world.lua.
function World:isNearRat(x, y)
Determine if any rat is near the given screen coordinates (relative to the
map origin). Compares against each nearby rat's drawn pixel position rather
than the tile it is anchored to, which can be up to a tile away while it
scurries.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | number | x-coordinate on the screen |
| y | number | y-coordinate on the screen |
Declared on: line 3168 of Lua/world.lua.
function World:isOnMap(x, y)
Test whether the given coordinate is on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the coordinate to test. |
| y | int | Y position of the coordinate to test. |
Declared on: line 1933 of Lua/world.lua.
function World:isPaused()
Check if game is currently paused
Declared on: line 839 of Lua/world.lua.
function World:isTileEmpty(x, y, not_in_room)
This function checks if a tile has no entity on it and (optionally) if it is not
in a room.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | integer | the queried tile's x coordinate. |
| y | integer | the queried tile's y coordinate. |
| not_in_room | boolean | If set, also check the tile is not in a room. |
Declared on: line 1524 of Lua/world.lua.
function World:isTileExclusivelyPassable(x, y, distance)
When placing doors and objects the passable tiles need to be checked for overlapping
passable tiles. This presents problems with objects like Bench where the passable tile
is not for exclusive use of the Bench (another object can share that same tile)
the footprint.shareable differentiates shareable passable tiles, and exclusive use
passable tiles (the norm for most objects)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | x map tile position |
| y | int | y map tile position |
| distance | int | searchable distance for nearby objects |
Declared on: line 3022 of Lua/world.lua.
function World:isTilePartOfNearbyObject(x, y, distance)
Checks whether the given tile is part of a nearby object (walkable tiles
count as part of the object)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | X position of the given tile. |
| y | ? | Y position of the given tile. |
| distance | ? | The number of tiles away from the tile to search. |
Declared on: line 1594 of Lua/world.lua.
function World:isUserActionProhibited()
Function to check if player can perform actions when paused
Declared on: line 881 of Lua/world.lua.
function World:localiseInitial(profile)
Change the staff name first letter to one from the current language
from the seed (generated here or in staff_profile.lua)
Parameters:
| Name | Type | Description |
|---|---|---|
| profile | table | The profile of the staff member |
Declared on: line 2533 of Lua/world.lua.
function World:loseGame(player_no, reason, limit)
Cause the player with the player number player_no to lose.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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 1443 of Lua/world.lua.
function World:makeAvailableStaff(month)
Parameters:
| Name | Type | Description |
|---|---|---|
| month | ? | ? |
Declared on: line 513 of Lua/world.lua.
function World:markRoomAsBuilt(room)
Called when a room has been completely built and is ready to use.
Parameters:
| Name | Type | Description |
|---|---|---|
| room | Room | The new room. |
Declared on: line 638 of Lua/world.lua.
function World:mustPauseWindowAdd()
Called when a must pause window comes into existence and pauses the game
Declared on: line 813 of Lua/world.lua.
function World:mustPauseWindowRemoved()
Called when a must pause window is closed and will attempt to unpause
the game
Declared on: line 819 of Lua/world.lua.
function World:newEntity(class, animation, mood_marker)
Create a new entity.
Parameters:
| Name | Type | Description |
|---|---|---|
| class | ? | Class to use for the new entity. |
| animation | int | animation to use. |
| mood_marker | int | Whether to use the first (default), or the second marker. |
Declared on: line 1816 of Lua/world.lua.
function World:newFloatingDollarSign(patient, amount)
Setup an animated floating money amount above a patient.
Parameters:
| Name | Type | Description |
|---|---|---|
| patient | ? | Patient to float above. |
| amount | ? | Amount of money to display. |
Declared on: line 1787 of Lua/world.lua.
function World:newLitter(litter_type, x, y, mirror)
Create a piece of litter on a tile, respecting the rank of any litter
already on that tile.
Parameters:
| Name | Type | Description |
|---|---|---|
| litter_type | string or or or int | Type passed on to Litter:setLitterType. |
| x | int | X position of the tile. |
| y | int | Y position of the tile. |
| mirror | int | Mirror flag passed on to Litter:setLitterType. |
Declared on: line 2365 of Lua/world.lua.
function World:newObject(id, x, y, flags, name)
Creates a new object by finding the object_type from the "id" variable and
calls its class constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
| id | string | The unique id of the object to be created. |
| x | ? | X position of the new object. |
| y | ? | Y position of the new object. |
| flags | ? | Flags of the new object. |
| name | ? | Name of the new object. |
Declared on: line 1881 of Lua/world.lua.
function World:newObjectType(new_object)
Parameters:
| Name | Type | Description |
|---|---|---|
| new_object | ? | ? |
Declared on: line 1877 of Lua/world.lua.
function World:newRoom(x, y, w, h, room_info, ...)
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| w | ? | ? |
| h | ? | ? |
| room_info | ? | ? |
| ... | ? | ? |
Declared on: line 625 of Lua/world.lua.
function World:nextEmergency()
Called when it is time to determine when the next emergency should happen
Declared on: line 1240 of Lua/world.lua.
function World:nextVip()
Called when it is time to have another VIP
Declared on: line 1314 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:
| Name | Type | Description |
|---|---|---|
| x | integer | The 1-based X coordinate of the tile to monitor. |
| y | integer | The 1-based Y coordinate 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 receive one argument (after `self`), which will be `1` for an enter event and `-1` for a leave event. |
Declared on: line 537 of Lua/world.lua.
function World:notifyRoomRemoved(room)
Called when a room has been deactivated (crashed or edited)
Parameters:
| Name | Type | Description |
|---|---|---|
| room | ? | ? |
Declared on: line 654 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:
| Name | Type | Description |
|---|---|---|
| entity | Entity | The entity that was just placed. |
| id | optional or string | That entity's id. |
Declared on: line 2246 of Lua/world.lua.
function World:onEndDay()
Called immediately prior to the ingame day changing.
Declared on: line 1052 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 1149 of Lua/world.lua.
function World:onEndYear()
Called immediately prior to the ingame year changing.
Declared on: line 1461 of Lua/world.lua.
function World:onTick()
World ticks (every 18ms) 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 907 of Lua/world.lua.
function World:pauseOrUnpause()
Dedicated function to allow unpausing by pressing 'p' again
Declared on: line 869 of Lua/world.lua.
function World:prepareFootprintTilesForBuild(object_footprint, x, y)
Prepare all tiles of the footprint for build of an object.
Parameters:
| Name | Type | Description |
|---|---|---|
| object_footprint | ? | Footprint of the object being build. |
| x | int | X position of the object |
| y | int | Y position of the object |
Declared on: line 2383 of Lua/world.lua.
function World:prepareRectangleTilesForBuild(x, y, w, h)
Prepare all tiles in the given rectangle for building a room.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | Start x position of the area. |
| y | int | Start y position of the area. |
| w | int | Number of tiles in x direction. |
| h | int | Number of tiles in y direction. |
Declared on: line 2398 of Lua/world.lua.
function World:previousSpeed()
Declared on: line 736 of Lua/world.lua.
function World:registerRoomRemoveCallback(callback)
Register a function to be called whenever a room has been deactivated (crashed or edited).
Parameters:
| Name | Type | Description |
|---|---|---|
| callback | function | A function taking one argument: a `Room`. |
Declared on: line 612 of Lua/world.lua.
function World:removeAllLitter(x, y)
Remove all cleanable litter from a given tile.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | X position of the tile to clean. |
| y | int | Y position of the tile to clean. |
Declared on: line 2349 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:
| Name | Type | Description |
|---|---|---|
| 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 2268 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 2496 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 3008 of Lua/world.lua.
function World:resetZoom()
Declared on: line 210 of Lua/world.lua.
function World:scheduleRandomEmergency(control)
If a level file specifies random emergencies we make the next one as defined by the mean/variance given
Parameters:
| Name | Type | Description |
|---|---|---|
| control | table | Contains emergency information from level file |
Declared on: line 1275 of Lua/world.lua.
function World:setCampaignData(campaign_data)
Restore the settings from the previous world
Parameters:
| Name | Type | Description |
|---|---|---|
| campaign_data | table | world and hospital campaign data |
Declared on: line 3069 of Lua/world.lua.
function World:setEndMonth()
Change the date of the game to the last hour of this month.
Declared on: line 1020 of Lua/world.lua.
function World:setEndYear()
Change the date of the game to the last hour of this year.
Declared on: line 1031 of Lua/world.lua.
function World:setPlotOwner(parcel, owner)
Change owner of a plot.
Parameters:
| Name | Type | Description |
|---|---|---|
| parcel | int | Plot to change. |
| owner | int | New owner (may be 0). |
Declared on: line 596 of Lua/world.lua.
function World:setSpeed(new_speed)
Set the (approximate) number of seconds per tick.
Parameters:
| Name | Type | Description |
|---|---|---|
| new_speed | string | New speed to set. One of: "Pause", "Slowest", "Slower", "Normal", "Max speed", or "And then some more". |
Declared on: line 766 of Lua/world.lua.
function World:setUI(ui)
Register key shortcuts for controlling the world (game speed, etc.)
Parameters:
| Name | Type | Description |
|---|---|---|
| ui | ? | ? |
Declared on: line 170 of Lua/world.lua.
function World:setUserPaused(state)
Update state of if game has been paused by user
Parameters:
| Name | Type | Description |
|---|---|---|
| state | boolean |
Declared on: line 845 of Lua/world.lua.
function World:setUserSpeed(new_speed)
Set game speed from a user-facing control.
Parameters:
| Name | Type | Description |
|---|---|---|
| new_speed | string | New speed to set. |
Declared on: line 757 of Lua/world.lua.
function World:spawnPatient(hospital)
Spawn a patient from a spawn point for the given hospital.
Parameters:
| Name | Type | Description |
|---|---|---|
| hospital | Hospital | Hospital that the new patient should visit. |
Declared on: line 428 of Lua/world.lua.
function World:spawnVIP(name)
A VIP is invited (or he invited himself) to the player hospital.
Parameters:
| Name | Type | Description |
|---|---|---|
| name | ? | Name of the VIP |
Declared on: line 474 of Lua/world.lua.
function World:speedUp()
Declared on: line 732 of Lua/world.lua.
function World:toggleInformation()
Declared on: line 277 of Lua/world.lua.
function World:unregisterRoomRemoveCallback(callback)
Unregister a function from being called whenever a room has been deactivated (crashed or edited).
Parameters:
| Name | Type | Description |
|---|---|---|
| callback | function | A function previously passed to `registerRoomRemoveCallback`. |
Declared on: line 618 of Lua/world.lua.
function World:updateInitialsCache()
Refresh cache of letters in current language to be used for staff member's initials
Declared on: line 2521 of Lua/world.lua.
function World:updateScreenBlueFilter()
Set the blue filter according to whether the user can build or not.
Declared on: line 864 of Lua/world.lua.
function World:updateUserActionsAllowed()
Set the "actions allowed" flag according to whether the user can do some actions with UI or not.
Declared on: line 857 of Lua/world.lua.
function World:updateUserInteractionState()
Refresh whether the user can interact with the game and presence of the
blue filter
Declared on: line 806 of Lua/world.lua.
function World:validateMap()
Perform validity tests on the map in world
Declared on: line 3078 of Lua/world.lua.
function World:wasEmergencySkipped(prev_date, new_date)
Checks if a time jump caused an emergency to be missed
Parameters:
| Name | Type | Description |
|---|---|---|
| prev_date | Date | Original game date before jump |
| new_date | Date | Game date after time jump |
Declared on: line 1042 of Lua/world.lua.
function World:willObjectsFootprintTileBeWithinItsAllowedRoomIfLocatedAt(x, y, object, allowed_rooms_id_parameter)
-
@param allowed_rooms_id_parameter Should be nil when the object is allowed to be placed in any room.
@return {within_room, roomId}
-
Parameters:
| Name | Type | Description |
|---|---|---|
| x | ? | ? |
| y | ? | ? |
| object | ? | ? |
| allowed_rooms_id_parameter | ? | ? |
Declared on: line 1941 of Lua/world.lua.
function World:winGame(player_no)
Process that the given player number won the game.
Parameters:
| Name | Type | Description |
|---|---|---|
| player_no | integer | Number of the player who just won. |
Declared on: line 1330 of Lua/world.lua.
function World:wouldNonSideObjectBreakPathfindingIfSpawnedAt(x, y, object, objects_orientation, room_id)
become when the object is placed), and then check that the cells
surrounding the footprint have not had their connectedness changed.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | integer | target tile x coordinate. |
| y | integer | target tile y coordinate. |
| object | object | target object for placing. |
| objects_orientation | table | object orientations description with footprints. |
| room_id | integer | target room for placing the object. |
Declared on: line 2009 of Lua/world.lua.
function World:wouldNonSideObjectsNotHaveAccessToRoomDoor(object_x, object_y, room, object_layout)
become when the object is placed), and then check that the
"use_position" cells have path to the room door.
Parameters:
| Name | Type | Description |
|---|---|---|
| object_x | integer | target tile x coordinate. |
| object_y | integer | target tile y coordinate. |
| room | object | target room for placing the object. |
| object_layout | table | object orientation description with footprint. |
Declared on: line 2089 of Lua/world.lua.
function World:wouldObjectBreakRoomObjectsAccessToTheRoomDoor(object_x, object_y, room, object_layout, is_side_object)
And then this function check that the "use_position" cells
of existing objects have path to the room door.
Parameters:
| Name | Type | Description |
|---|---|---|
| object_x | integer | target tile x coordinate. |
| object_y | integer | target tile y coordinate. |
| room | object | target room for placing the object. |
| object_layout | table | object orientation description with footprint. |
| is_side_object | bool | is that object is side object. |
Declared on: line 2160 of Lua/world.lua.