obj.AvatarControl - originalfoo/Prison-Architect-API GitHub Wiki
This property requires further investigation
Bug: Setting the value of this property can crash the game
##Overview
[
](Avatar (Entity)) [
](Prisoner (Entity))
In escape mode, this property of Prisoner and Avatar entity objects indicates whether the player can or is controlling them (not sure which yet).
##Syntax
-- get
local userCanControl = someEntity.AvatarControl -- <value>
-- set
someEntity.AvatarControl = <value> -- does not seem to workWhere someEntity is either a Prisoner or Avatar type of entity, and <value> can be one of the following:
-
true- the player can control the entity -
false- the player can not control the entity -
nil- equivalent meaning tofalse
Setting the value of this property generally has no effect, other than sometimes crashing the game (eg. if you try setting it on a Warden object). As such it should be treated as a read-only property.
##Example
-- find all .AvatarControl entities
local controllable = {} -- to store the list
local function AddToList( type, list )
local entities = this.GetNearbyObjects( type, 9001 )
for entity in next, entities do
if entity.AvatarControl then
controllable[ #controllable + 1 ] = entity
end
end
end
AddToList( 'Prisoner' )
AddToList( 'Avatar' )##Notes
The Avatar represents the entity that the user was initially playing as, and any Prisoner entities with the property will have been added to the players group (and can also be controlled by the player, even if the original Avatar entity is killed and removed from the map).
##See Also