Humanoid Class
An `Entity` which occupies a single tile and is capable of moving around the map.
Inheritance: Humanoid ยป Entity
Subclasses: GrimReaper, Inspector, Patient, Staff, Vip
Method Index
- _handleEmptyActionQueue()
- _tick() (inherited from Entity)
- afterLoad(old, new) (overrides Entity:afterLoad)
- changeAttribute(attribute, amount)
- clearDynamicInfo() (inherited from Entity)
- despawn()
- dump()
- eraseObject() (inherited from Entity)
- findObjectsInSquare(size, object_spec)
- finishAction(action)
- getAttribute(attribute, default_value)
- getCurrentAction()
- getCurrentMood()
- getDrawingLayer() (inherited from Entity)
- getDynamicInfo() (inherited from Entity)
- getIdleAnimation(humanoid_class)
- getRoom() (overrides Entity:getRoom)
- getTile() (inherited from Entity)
- goingToUseObject(object_type)
- handleRemovedObject(object)
- hasDressingAndLeavingAction()
- hasLeavingAction()
- isEnteringRoom()
- isKnockingDoor()
- isLeaving()
- isMeandering()
- isMoodActive(mood)
- isObscuringArea(x1, x2, y1, y2)
- isType(humanoid_class)
- leaveArea()
- notifyNewObject(id) (inherited from Entity)
- notifyNewRoom(room) (overrides Entity:notifyNewRoom)
- notifyOfStaffChange(staff)
- onClick(ui, button)
- onDestroy() (overrides Entity:onDestroy)
- onPickUp() (inherited from Entity)
- playAfterLoadSound() (inherited from Entity)
- playEntitySounds(name_pattern, min_silence_lengths, max_silence_lengths, num_silences) (inherited from Entity)
- playSound(name, played_callback, played_callback_delay) (inherited from Entity)
- queueAction(action, pos)
- registerRoomBuildCallback(callback)
- registerRoomRemoveCallback(callback)
- registerStaffChangeCallback(callback)
- resetAnimation() (inherited from Entity)
- setAnimation(animation, flags) (inherited from Entity)
- setCallCompleted()
- setDynamicInfo(type, value) (inherited from Entity)
- setHospital(hospital)
- setIfHoverMoodsVisible()
- setLayer(layer, id) (inherited from Entity)
- setMood(mood_name, activate) (overrides Entity:setMood)
- setMoodInfo(new_mood) (inherited from Entity)
- setNextAction(action, high_priority)
- setPosition(x, y) (inherited from Entity)
- setSpeed(x, y) (inherited from Entity)
- setTile(x, y) (inherited from Entity)
- setTilePositionSpeed(tx, ty, px, py, sx, sy) (inherited from Entity)
- setTimer(tick_count, f) (inherited from Entity)
- setType(humanoid_class)
- setWaitingForSoundEffectsToBeTurnedOn() (inherited from Entity)
- startAction()
- tick() (inherited from Entity)
- tickDay() (overrides Entity:tickDay)
- tire(amount)
- tostring()
- unexpectFromRoom(dest_room)
- unregisterCallbacks()
- unregisterRoomBuildCallback(callback)
- unregisterRoomRemoveCallback(callback)
- unregisterStaffChangeCallback(callback)
- updateSpeed()
- wake(amount)
- walkTo(tile_x, tile_y, must_happen)
Member Index
- action_queue
- active_moods
- animation_flags (*)
- animation_idx (*)
- associated_desk
- attributes
- build_callback
- build_callbacks
- check_watch_anim
- dead
- die_anims
- door_anims
- dynamic_info (*)
- falling_anim
- fire
- getServiceQuality
- get_up_anim
- goHome
- going_home
- going_to_die
- has_fallen
- has_vomitted
- hospital
- hover_moods
- humanoid_class
- in_room
- last_move_direction
- layers (*)
- message_callback
- mood_info
- mood_marker (*)
- next_room_to_visit
- num_animation_ticks (*)
- on_call
- on_ground_anim
- pee_anim
- permanent_flags
- playing_sounds_in_random_sequence (*)
- previous_action
- profile
- random_sound_sequence_parameters (*)
- remove_callbacks
- shake_fist_anim
- should_knock_on_doors
- skip_next_tick (*)
- slow_animation (*)
- speed
- staff_change_callbacks
- tap_foot_anim
- th
- ticks (*)
- tile_x
- tile_y
- timer_function (*)
- timer_time (*)
- toilet_callback
- user_of
- vomit_anim
- waiting_for_sound_effects_to_be_turned_on (*)
- walk_anims
- world
- yawn_anim
function Humanoid:Humanoid(...)
Parameters:
| Name | Type | Description |
|---|---|---|
| ... | ? | 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:despawn()
Despawn the humanoid.
Declared on: line 466 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| action | ? | ? |
Declared on: line 699 of Lua/entities/humanoid.lua.
function Humanoid:getAttribute(attribute, default_value)
Get attribute value
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| humanoid_class | ? | ? |
Declared on: line 525 of Lua/entities/humanoid.lua.
Note: Is a function rather than a method.
function Humanoid:getRoom()
Overrides: Entity:getRoom.
Declared on: line 429 of Lua/entities/humanoid.lua.
function Humanoid:goingToUseObject(object_type)
Helper function that finds out if there is an action queued to use the specified object
Parameters:
| Name | Type | Description |
|---|---|---|
| object_type | ? | ? |
Declared on: line 1022 of Lua/entities/humanoid.lua.
function Humanoid:handleRemovedObject(object)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| room | ? | ? |
Overrides: Entity:notifyNewRoom.
Declared on: line 1048 of Lua/entities/humanoid.lua.
function Humanoid:notifyOfStaffChange(staff)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| action | ? | ? |
| pos | ? | ? |
Declared on: line 686 of Lua/entities/humanoid.lua.
function Humanoid:registerRoomBuildCallback(callback)
Registers a new build callback for this humanoid.
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| mood_name | ? | ? |
| activate | ? | ? |
Overrides: Entity:setMood.
Declared on: line 472 of Lua/entities/humanoid.lua.
function Humanoid:setNextAction(action, high_priority)
Parameters:
| Name | Type | Description |
|---|---|---|
| action | ? | ? |
| high_priority | ? | ? |
Declared on: line 615 of Lua/entities/humanoid.lua.
function Humanoid:setType(humanoid_class)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| callback | function | The callback to remove. |
Declared on: line 1091 of Lua/entities/humanoid.lua.
function Humanoid:wake(amount)
Parameters:
| Name | Type | Description |
|---|---|---|
| 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:
| Name | Type | Description |
|---|---|---|
| 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.