obj.Energy - originalfoo/Prison-Architect-API GitHub Wiki

This property requires further investigation

##Overview

Entities

This property is applicable to all (need to check) Entities and determines how much energy they have remaining.

##Syntax

-- get:
local energy = someEntity.Energy -- <number>

-- set:
someEntity.Energy = <number>

Where <number> is an integer in the range 0 to 100:

  • A value of 0 means they have no energy left
  • A value of 100 means they have full energy

##Example

-- give nearby Guard entities full energy

-- shortcuts:
local find = this.GetNearbyObjects

for guard in next, find( 'Guard', 50 ) do
  guard.Energy = 100
end

##Example Mods

  • Tired Armed Guards mod - allows [ArmedGuard entities](ArmedGuard (Entity)) to become tired and makes them rest in the [Armoury room](Armoury (Room)).

##Notes

This property appears to exist on all Entities:

  • An entities' .Energy will automatically decrease throughout the day, unless they have the Properties DoesNotTire setting in their materials.txt definition block
  • While [Prisoner entities](Prisoner (Entity)) also have the property, their resting requirements are primarily handled by their .Needs.Sleep (need to test whether their .Energy plays a role in that)

##See Also


The value of Energy can be below 0 and thus make the entity exhausted and unable to move.

The prisoners' Sleep need is just a need and has nothing to do with Energy.

-- Contributor: GrandSong

⚠️ **GitHub.com Fallback** ⚠️