CorsixTH Lua Documentation

Humanoid Class

An `Entity` which occupies a single tile and is capable of moving around the map.

Declared on: line 21 of Lua/entities/humanoid.lua.
Inheritance: Humanoid ยป Entity
Subclasses: GrimReaper, Inspector, Patient, Staff, Vip

Method Index

Member Index

(*) only used in superclass methods
function Humanoid:Humanoid(...)

Parameters:

NameTypeDescription
... ? Arguments for base class constructor.

Declared on: line 338 of Lua/entities/humanoid.lua.

function Humanoid:_handleEmptyActionQueue()

Handle an empty action queue in some way instead of crashing.

Declared on: line 747 of Lua/entities/humanoid.lua.

function Humanoid:afterLoad(old, new)

Save game compatibility

Parameters:

NameTypeDescription
old ? ?
new ? ?

Overrides: Entity:afterLoad.
Declared on: line 360 of Lua/entities/humanoid.lua.

function Humanoid:changeAttribute(attribute, amount)

Adjusts one of the `Humanoid`'s attributes.

Parameters:

NameTypeDescription
attribute string One of: "happiness", "thirst", "toilet_need", "warmth".
amount number This amount is added to the existing value for the attribute, and is then capped to be between 0 and 1.

Declared on: line 955 of Lua/entities/humanoid.lua.

function Humanoid:findObjectsInSquare(size, object_spec)

Collect the objects in a square around the humanoid within the same room.

Parameters:

NameTypeDescription
size int Size of the square to be searched, as number of rows/columns around the humanoid. Size 0 only searches the tile of the humanoid, size 1 adds the 8 tiles around the humanoid (one tile in all directions), and so on.
object_spec str or or or array or str Name(s) of objects to find.

Declared on: line 535 of Lua/entities/humanoid.lua.

function Humanoid:finishAction(action)

Parameters:

NameTypeDescription
action ? ?

Declared on: line 699 of Lua/entities/humanoid.lua.

function Humanoid:getAttribute(attribute, default_value)

Get attribute value

Parameters:

NameTypeDescription
attribute string
default_value float Number to return if none found. If neither are present, 0 is returned

Declared on: line 1207 of Lua/entities/humanoid.lua.

function Humanoid.getIdleAnimation(humanoid_class)

Parameters:

NameTypeDescription
humanoid_class ? ?

Declared on: line 525 of Lua/entities/humanoid.lua.
Note: Is a function rather than a method.

function Humanoid:goingToUseObject(object_type)

Helper function that finds out if there is an action queued to use the specified object

Parameters:

NameTypeDescription
object_type ? ?

Declared on: line 1022 of Lua/entities/humanoid.lua.

function Humanoid:handleRemovedObject(object)

Parameters:

NameTypeDescription
object ? ?

Declared on: line 923 of Lua/entities/humanoid.lua.

function Humanoid:hasDressingAndLeavingAction()

Check if there is "use_screen is_leaving" action in the action queue

Declared on: line 737 of Lua/entities/humanoid.lua.

function Humanoid:hasLeavingAction()

Check if there is "is_leaving" action in the action queue

Declared on: line 727 of Lua/entities/humanoid.lua.

function Humanoid:isEnteringRoom()

Check if the humanoid is entering room

Declared on: line 719 of Lua/entities/humanoid.lua.

function Humanoid:isKnockingDoor()

Check if the humanoid is knocking on a door

Declared on: line 714 of Lua/entities/humanoid.lua.

function Humanoid:isLeaving()

Check if the humanoid is running actions intended to leave the room, as indicated by the flag

Declared on: line 709 of Lua/entities/humanoid.lua.

function Humanoid:isMeandering()

Check whether humanoids (staff and Inspector) are meandering

Declared on: line 1251 of Lua/entities/humanoid.lua.

function Humanoid:isMoodActive(mood)

Is the given mood in the list of active moods.

Parameters:

NameTypeDescription
mood ? ?

Declared on: line 510 of Lua/entities/humanoid.lua.

function Humanoid:isObscuringArea(x1, x2, y1, y2)

Checks whether a humanoid is within the specified area or is currently walking into it. To properly check whether a humanoid is entering an area, pass coordinates 1 tile outside the square where actually need to build. For example, if the intended wall of the room being built is outside the perimeter (x1, y1) (x2, y2), then need to pass (x1-1, y1-1) (x2+1, y2+1). Example input parameters: (50, 55, 60, 65).

Parameters:

NameTypeDescription
x1 int north-west X position of target area.
x2 int south-east X position of target area.
y1 int north-west Y position of target area.
y2 int south-east Y position of target area.

Declared on: line 1215 of Lua/entities/humanoid.lua.

function Humanoid:isType(humanoid_class)

Parameters:

NameTypeDescription
humanoid_class ? ?

Declared on: line 845 of Lua/entities/humanoid.lua.

function Humanoid:leaveArea()

Function attempts to expel the humanoid from the area. It does not require any input parameters since it expects that the area to be left is already marked with the `avoidTile` tile flag.

Declared on: line 863 of Lua/entities/humanoid.lua.

function Humanoid:notifyNewRoom(room)

Parameters:

NameTypeDescription
room ? ?

Overrides: Entity:notifyNewRoom.
Declared on: line 1048 of Lua/entities/humanoid.lua.

function Humanoid:notifyOfStaffChange(staff)

Parameters:

NameTypeDescription
staff ? ?

Declared on: line 1054 of Lua/entities/humanoid.lua.

function Humanoid:onClick(ui, button)

Function which is called when the user clicks on the `Humanoid`.

Parameters:

NameTypeDescription
ui GameUI The UI which the user in question is using.
button string One of: "left", "middle", "right".

Declared on: line 420 of Lua/entities/humanoid.lua.

function Humanoid:onDestroy()

Called when the humanoid is about to be removed from the world.

Overrides: Entity:onDestroy.
Declared on: line 440 of Lua/entities/humanoid.lua.

function Humanoid:queueAction(action, pos)

Parameters:

NameTypeDescription
action ? ?
pos ? ?

Declared on: line 686 of Lua/entities/humanoid.lua.

function Humanoid:registerRoomBuildCallback(callback)

Registers a new build callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to call when a room has been built.

Declared on: line 1032 of Lua/entities/humanoid.lua.

function Humanoid:registerRoomRemoveCallback(callback)

Registers a new remove callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to call when a room has been removed.

Declared on: line 1060 of Lua/entities/humanoid.lua.

function Humanoid:registerStaffChangeCallback(callback)

Registers a new staff change callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to call when a staff member has been hired or fired

Declared on: line 1081 of Lua/entities/humanoid.lua.

function Humanoid:setHospital(hospital)

Set the `Hospital` which is responsible for treating or employing the `Humanoid`. In single player games, this has little effect, but it is very important in multiplayer games.

Parameters:

NameTypeDescription
hospital Hospital The `Hospital` which should be responsible for the `Humanoid`.

Declared on: line 454 of Lua/entities/humanoid.lua.

function Humanoid:setIfHoverMoodsVisible()

Set whether this humanoid should display its mood on hover.

Declared on: line 520 of Lua/entities/humanoid.lua.

function Humanoid:setMood(mood_name, activate)

Function to activate/deactivate moods of a humanoid. If mood_name is nil it is considered a refresh only.

Parameters:

NameTypeDescription
mood_name ? ?
activate ? ?

Overrides: Entity:setMood.
Declared on: line 472 of Lua/entities/humanoid.lua.

function Humanoid:setNextAction(action, high_priority)

Parameters:

NameTypeDescription
action ? ?
high_priority ? ?

Declared on: line 615 of Lua/entities/humanoid.lua.

function Humanoid:setType(humanoid_class)

Parameters:

NameTypeDescription
humanoid_class ? ?

Declared on: line 816 of Lua/entities/humanoid.lua.

function Humanoid:startAction()

Start the next (always first) action in the queue.

Declared on: line 587 of Lua/entities/humanoid.lua.

function Humanoid:tickDay()

Check if it is cold or hot around the humanoid and increase/decrease the feeling of warmth accordingly. Returns whether the calling function should proceed.

Overrides: Entity:tickDay.
Declared on: line 984 of Lua/entities/humanoid.lua.

function Humanoid:tire(amount)

Stub functions for handling fatigue. These are overridden by the staff subclass, but also defined here, so we can just call it on any humanoid

Parameters:

NameTypeDescription
amount ? ?

Declared on: line 911 of Lua/entities/humanoid.lua.

function Humanoid:tostring()

Return string representation

Returns string representation of the humanoid like status and action queue

Declared on: line 1133 of Lua/entities/humanoid.lua.

function Humanoid:unexpectFromRoom(dest_room)

Unexpects humanoid from a room, if validly entering this room

Parameters:

NameTypeDescription
dest_room Room The room the humanoid maybe expected at

Declared on: line 1191 of Lua/entities/humanoid.lua.

function Humanoid:unregisterCallbacks()

Function called when a humanoid is sent away from the hospital to prevent further actions taken as a result of a callback

Declared on: line 1103 of Lua/entities/humanoid.lua.

function Humanoid:unregisterRoomBuildCallback(callback)

Unregisters a build callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to remove.

Declared on: line 1042 of Lua/entities/humanoid.lua.

function Humanoid:unregisterRoomRemoveCallback(callback)

Unregisters a remove callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to remove.

Declared on: line 1071 of Lua/entities/humanoid.lua.

function Humanoid:unregisterStaffChangeCallback(callback)

Unregisters a staff change callback for this humanoid.

Parameters:

NameTypeDescription
callback function The callback to remove.

Declared on: line 1091 of Lua/entities/humanoid.lua.

function Humanoid:wake(amount)

Parameters:

NameTypeDescription
amount ? ?

Declared on: line 916 of Lua/entities/humanoid.lua.

function Humanoid:walkTo(tile_x, tile_y, must_happen)

Helper function for the common case of instructing a `Humanoid` to walk to a position on the map. Equivalent to calling `setNextAction` with a walk action.

Parameters:

NameTypeDescription
tile_x integer The X-component of the Lua tile coordinates of the tile to walk to.
tile_y integer The Y-component of the Lua tile coordinates of the tile to walk to.
must_happen boolean or nil If true, then the walk action will not be interrupted.

Declared on: line 849 of Lua/entities/humanoid.lua.