Autonauts Modding
ModObject Class Reference

Public Member Functions

void StartMoveTo (int UID, int NewX, int NewY, float Speed=10f, float Height=0f)
 
bool UpdateMoveTo (int UID, bool Arc=false, bool Wobble=false)
 
void MoveToInstantly (int UID, int NewX, int NewY)
 
Table GetObjectTileCoord (int UID)
 
bool IsValidObjectUID (int UID)
 
bool DestroyObject (int UID)
 
string GetObjectType (int UID)
 
bool IsWearingClothing (int UID, string ClothingType)
 
Table GetClothingTypesWorn (int UID)
 
int GetClothingUIDOnObject (int UID, string ClothingType)
 
Table GetObjectProperties (int UID)
 
void SetObjectRotation (int UID, float RotX=0f, float RotY=0f, float RotZ=0f)
 
string GetObjectCategory (int UID)
 
string GetObjectSubcategory (int UID)
 
void SetObjectDurability (int UID, int Durability)
 
int GetObjectDurability (int UID)
 
void SetObjectActive (int UID, bool Active)
 
void SetObjectVisibility (int UID, bool Visible)
 
bool AddObjectToColonistHouse (int HousingUID, int ObjectUID)
 
bool RepairColonistHouseWithObject (int HousingUID, int ObjectUID)
 

Member Function Documentation

◆ AddObjectToColonistHouse()

bool ModObject.AddObjectToColonistHouse ( int  HousingUID,
int  ObjectUID 
)

Add an item to the colonist housing (Food, Education etc.)

Version
137.16
Parameters
HousingUID- Number (integer) - the unique ID of the HOUSING object - Required
ObjectUID- Number (integer) - the unique ID of the OBJECT to add - Required
Returns
Boolean - True if successful
Example
ModObject.AddObjectToColonistHouse(HouseId, ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ DestroyObject()

bool ModObject.DestroyObject ( int  UID)

Destroy an Object by UID - this is dangerous! Make sure the object is free from all use (not being held etc.)

Version
135.18
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Boolean - True if deleted
Example
ModObject.DestroyObject(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetClothingTypesWorn()

Table ModObject.GetClothingTypesWorn ( int  UID)

Get the Type of clothing object (e.g. Farmer or Bot) is wearing

Version
135.18
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Table (Strings) - All the types of clothing worn by object
Example
Types = ModObject.GetClothingTypesWorn(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetClothingUIDOnObject()

int ModObject.GetClothingUIDOnObject ( int  UID,
string  ClothingType 
)

Get the UID of clothing that object (e.g. Farmer or Bot) is wearing (Specifying an exact type)

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the object - Required
ClothingType- String - the type of clothing to check for - Required [e.g. 'HatBeret']
Returns
Number (Integer) - UID of the clothing object (-1 if failed)
Example
ModObject.GetClothingUIDOnObject(ObjId, "HatBeret")
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectCategory()

string ModObject.GetObjectCategory ( int  UID)

Get Object Category from UID

Version
136.22
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
String - The Object Category e.g. 'Food'
Example
Category = ModObject.GetObjectCategory(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectDurability()

int ModObject.GetObjectDurability ( int  UID)

Get durability/usage of a Holdable Object by UID

Version
137.18
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Boolean - Returns current durability (-1 if not found)
Example
ModObject.GetObjectDurability(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectProperties()

Table ModObject.GetObjectProperties ( int  UID)

Get the properties of a given object providing the object's unique ID

Version
136.22
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Table (Mixed) - Properties [1]=Type, [2]=TileX, [3]=TileY, [4]=Rotation, [5]=Name,
Example
Info = ModObject.GetObjectProperties(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectSubcategory()

string ModObject.GetObjectSubcategory ( int  UID)

Get Object Subcategory from UID

Version
136.22
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
String - The Object Subcategory e.g. 'FoodMushroom'
Example
Subcategory = ModObject.GetObjectSubcategory(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectTileCoord()

Table ModObject.GetObjectTileCoord ( int  UID)

Get the Tilecoords of an Object from passed in ID

Version
135.6
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Position - Table ([1] is X, [2] is Y) - The Tile Coordinate
Example
ModObject.GetObjectTileCoord(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetObjectType()

string ModObject.GetObjectType ( int  UID)

Get Object Type from UID

Version
135.16
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
String - The Object Type e.g. 'ToolAxe'
Example
Type = ModObject.GetObjectType(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsValidObjectUID()

bool ModObject.IsValidObjectUID ( int  UID)

Is this Unique ID of object valid?

Version
135.16
Parameters
UID- Number (integer) - the unique ID of the object - Required
Returns
Boolean - True if valid
Example
ModObject.IsValidObjectUID(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsWearingClothing()

bool ModObject.IsWearingClothing ( int  UID,
string  ClothingType 
)

Get if the object (e.g. Farmer or Bot) is wearing a piece of defined clothing

Version
135.18
Parameters
UID- Number (integer) - the unique ID of the object - Required
ClothingType- String - the type of clothing to check for - Required [Choose from "Hat" or "Top"]
Returns
Boolean - True if the object is wearing that type of clothing. Returns false if item is not worn OR object not found
Example
ModObject.IsWearingClothing(ObjId, "Hat")
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ MoveToInstantly()

void ModObject.MoveToInstantly ( int  UID,
int  NewX,
int  NewY 
)

Move an Object to a desired location

Version
136.19
Parameters
UID- Number (integer) - the unique ID of the object to move - Required
NewX- Number (integer) - X Position (to move to) in tile coordinates - Required
NewY- Number (integer) - Y Position (to move to) in tile coordinates - Required
Returns
None
Example
ModObject.MoveToInstantly(ObjId, 23, 56)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), Update()

◆ RepairColonistHouseWithObject()

bool ModObject.RepairColonistHouseWithObject ( int  HousingUID,
int  ObjectUID 
)

Repair colonist housing by providing the object

Version
137.16
Parameters
HousingUID- Number (integer) - the unique ID of the HOUSING object - Required
ObjectUID- Number (integer) - the unique ID of the OBJECT to repair with - Required
Returns
Boolean - True if successful
Example
ModObject.RepairColonistHouseWithObject(HouseId, ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetObjectActive()

void ModObject.SetObjectActive ( int  UID,
bool  Active 
)

Set object active by UID (Inactive means invisible and won't tick/respond etc. (Disabled))

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the object - Required
Active- Boolean - Active state of the item - Required
Example
ModObject.SetObjectActive(ObjId, true)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetObjectDurability()

void ModObject.SetObjectDurability ( int  UID,
int  Durability 
)

Set durability/usage of a Holdable Object by UID

Version
136.26
Parameters
UID- Number (integer) - the unique ID of the object - Required
Durability- Number (integer) - the durability to set for the item - Required
Returns
Boolean - True if successfully set
Example
ModObject.SetObjectDurability(ObjId, 3)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetObjectRotation()

void ModObject.SetObjectRotation ( int  UID,
float  RotX = 0f,
float  RotY = 0f,
float  RotZ = 0f 
)

Set rotation of an Object by UID

Version
136.19
Parameters
UID- Number (integer) - the unique ID of the object - Required
RotX- Number (float) - Rotation (X) of the model - Defaults to 0
RotY- Number (float) - Rotation (Y) of the model - Defaults to 0
RotZ- Number (float) - Rotation (Z) of the model - Defaults to 0
Returns
None
Example
ModObject.SetObjectRotation(ObjId, 90, 0, 0)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate() If modifying a building, use ModBuilding.SetRotation instead.

◆ SetObjectVisibility()

void ModObject.SetObjectVisibility ( int  UID,
bool  Visible 
)

Set object visibility by UID (Still operational, just hidden if invisible)

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the object - Required
Visible- Boolean - Visibility of the item - Required
Example
ModObject.SetObjectVisibility(ObjId, true)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ StartMoveTo()

void ModObject.StartMoveTo ( int  UID,
int  NewX,
int  NewY,
float  Speed = 10f,
float  Height = 0f 
)

Setup the Moving of an Object - Crude 'any object' version - doesn't use pathfinding - Use with ModBase.UpdateMoveTo()

Version
134.30
Parameters
UID- Number (integer) - the unique ID of the object to move - Required
NewX- Number (integer) - X Position (to move to) in tile coordinates - Required
NewY- Number (integer) - Y Position (to move to) in tile coordinates - Required
Speed- Number (float) - The speed object should wobble along a sine wave (like the Bee) - Defaults to 10.f
Height- Number (float) - The max height object should reach along a sine wave (like the Bee) - Defaults to 0.0f
Returns
None
Example
ModObject.StartMoveTo(ObjId, 0,0, 10, 0) – Only call once
(Example Lua)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ UpdateMoveTo()

bool ModObject.UpdateMoveTo ( int  UID,
bool  Arc = false,
bool  Wobble = false 
)

Update the Moving Object - Use only on Update() - Must be setup with ModBase.StartMoveTo()

Version
134.30
Parameters
UID- Number (integer) - the unique ID of the object to move - Required
Arc- Boolean - If the object should follow an arc trajectory (starts at zero, mid point is max height) - Defaults to false
Wobble- Boolean - If the object should wobble along a sine wave (like the Bee) - Defaults to false
Returns
true when complete, false if still needs to be called
Example
MoveComplete = ModObject.UpdateMoveTo(ObjId, true, true)
(Example Lua)
Note
Can be used in functions: Update()

The documentation for this class was generated from the following file: