Autonauts Modding
ModBuilding Class Reference
Inheritance diagram for ModBuilding:
ModCustom

Public Member Functions

void CreateBuilding (string UniqueName, string[] NewIngredientsStringArr, int[] NewIngredientsAmountArr, string ModelName="", int[] TL=null, int[] BR=null, int[] Access=null, bool UsingCustomModel=true)
 
bool IsBuildingActuallyFlooring (int UID)
 
int[] GetAllBuildingsUIDsOfType (string NewTypeString, int StartX, int StartY, int EndX, int EndY)
 
int[] GetBuildingsUIDsRequiringIngredientInArea (string IngredientString, int StartX, int StartY, int EndX, int EndY)
 
void SetBuildingWalkable (string NewTypeString, bool CanBeWalkedThrough)
 
int GetBuildingCoveringTile (int PosX, int PosY, bool AllowFlooring=false, bool AllowWalls=false, bool AllowFootprintTiles=false)
 
Table GetAllBuildingsUIDsFromName (string DesiredName)
 
bool AddEnergy (int UID, float EnergyAmount, bool SetToMax=false)
 
bool AddWater (int UID, float WaterAmount, bool SetToMax=false)
 
bool AddFuel (int UID, float FuelAmount, bool SetToMax=false)
 
float GetFuelMaxCapacity (int UID)
 
void ShowBuildingAccessPoint (string NewTypeString, bool EnableAccessPoint)
 
bool SetBuildingName (int UID, string BuildingName)
 
bool SetRotation (int UID, int Rotation)
 
int GetRotation (int UID)
 
bool IsBuildingSaveable (int UID)
 
void RegisterForBuildingEditedCallback (int BuildingUID, DynValue Callback)
 
void UnregisterForBuildingEditedCallback (int BuildingUID)
 
void RegisterForNewBuildingInAreaCallback (int StartX, int StartY, int EndX, int EndY, DynValue Callback)
 
void UnregisterForNewBuildingInAreaCallback (int StartX, int StartY, int EndX, int EndY)
 
void RegisterForBuildingTypeSpawnedCallback (string NewTypeString, DynValue Callback)
 
- Public Member Functions inherited from ModCustom
void UpdateModelParameters (string UniqueName, float Scale=1f, float RotX=0f, float RotY=0f, float RotZ=0f, float TransX=0f, float TransY=0f, float TransZ=0f)
 
void UpdateModelScale (string UniqueName, float Scale=1f)
 
void UpdateModelScaleSplit (string UniqueName, float ScaleX=1f, float ScaleY=1f, float ScaleZ=1f)
 
void UpdateModelRotation (string UniqueName, float RotX=0f, float RotY=0f, float RotZ=0f)
 
void UpdateModelTranslation (string UniqueName, float TransX=0f, float TransY=0f, float TransZ=0f)
 
void RegisterForCustomCallback (string UniqueName, string CallbackType, DynValue Callback)
 

Member Function Documentation

◆ AddEnergy()

bool ModBuilding.AddEnergy ( int  UID,
float  EnergyAmount,
bool  SetToMax = false 
)

Add Energy to a Power Building (e.g. Windmill, GiantWaterWheel, StationaryEngine)

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the power building object - Required
EnergyAmount- Number (float) - energy to add to building - Required
SetToMax- Boolean - if energy should be filled to max capacity - Defaults to false
Returns
Boolean - True if successfully added to energy
Example
Amount = ModBuilding.AddEnergy(ObjId, 5, false)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ AddFuel()

bool ModBuilding.AddFuel ( int  UID,
float  FuelAmount,
bool  SetToMax = false 
)

Add Fuel to a Building that allows it (e.g. TrainRefuellingStation, StationaryEngine)

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the building object - Required
FuelAmount- Number (float) - Fuel to add to building - Required
SetToMax- Boolean - if Fuel should be filled to max capacity - Defaults to false
Returns
Boolean - True if successfully added to the Fuel
Example
Amount = ModBuilding.AddFuel(ObjId, 10, false)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ AddWater()

bool ModBuilding.AddWater ( int  UID,
float  WaterAmount,
bool  SetToMax = false 
)

Add Water to a Building that allows it (e.g. TrainRefuellingStation, StationaryEngine)

Version
137.14
Parameters
UID- Number (integer) - the unique ID of the building object - Required
WaterAmount- Number (float) - water to add to building - Required
SetToMax- Boolean - if water should be filled to max capacity - Defaults to false
Returns
Boolean - True if successfully added to the water
Example
Amount = ModBuilding.AddWater(ObjId, 10, false)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ CreateBuilding()

void ModBuilding.CreateBuilding ( string  UniqueName,
string[]  NewIngredientsStringArr,
int[]  NewIngredientsAmountArr,
string  ModelName = "",
int[]  TL = null,
int[]  BR = null,
int[]  Access = null,
bool  UsingCustomModel = true 
)

Create a custom building

Version
134.29
Parameters
UniqueName- String - The unique and corresponding name of the building - Required
NewIngredientsStringArr- String array - List of ingredients required to make the building - Defaults to none
NewIngredientsAmountArr- Number (integer) array - The amount of each of the ingredients (Must match size of ingredients array) - Defaults to none
ModelName- String - The name/path of the custom model to use or name/path of the in game model to use - Defaults to in game 'BlockWall' Model
TL- Number (integer) array - Top Left ground coordinates of the building (for area) e.g. (-1,-1) - Defaults to none
BR- Number (integer) array - Bottom Right ground coordinates of the building (for area) e.g. (2,0) - Defaults to none
Access- Number (integer) array - Access point ground coordinates of the building e.g. (1,1) - Defaults to none
UsingCustomModel- Boolean - True if using a custom model, false if using in game model/default model - Defaults to true
Returns
None
Example
ModBuilding.CreateBuilding("Building1") – Default Model
ModBuilding.CreateBuilding("Building2", {"Stick"}, {1}) – Default Model
ModBuilding.CreateBuilding("Building3", {"Stick"}, {1}, "Models/Buildings/BrickWall", {-1,-1}, {1,0}, {0,1}, false) – In Game Model
ModBuilding.CreateBuilding("Building4", {"Stick"}, {1}, "ObjCrates/wooden boxes pack", {-1,-1}, {1,0}, {0,1}, true) – Custom Model
Note
Can be used in functions: Creation()

◆ GetAllBuildingsUIDsFromName()

Table ModBuilding.GetAllBuildingsUIDsFromName ( string  DesiredName)

Get the unique IDs of buildings matching the desired name provided

Version
136.27
Parameters
DesiredName- String - Name of the building to search for - Required
Returns
Table (Number - integer) - An array of all the unique IDs of all the buildings with specified name
Example
UIDs = ModBuilding.GetAllBuildingsUIDsFromName("Workbench")
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetAllBuildingsUIDsOfType()

int [] ModBuilding.GetAllBuildingsUIDsOfType ( string  NewTypeString,
int  StartX,
int  StartY,
int  EndX,
int  EndY 
)

Get the unique IDs of buildings of type in a specified area

Version
136.19
Parameters
NewTypeString- String - The building type to search for - Required
StartX- Number (integer) - The location to start the search from (X) - Required
StartY- Number (integer) - The location to start the search from (Y) - Required
EndX- Number (integer) - The location to end the search at (X) - Required
EndY- Number (integer) - The location to end the search at (Y) - Required
Returns
Table (Number - integer) - An array of all the unique IDs of all the buildings in the area specified
Example
UIDs = ModBuilding.GetAllBuildingsUIDsOfType("Workbench", 0,0, 50,80)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetBuildingCoveringTile()

int ModBuilding.GetBuildingCoveringTile ( int  PosX,
int  PosY,
bool  AllowFlooring = false,
bool  AllowWalls = false,
bool  AllowFootprintTiles = false 
)

Get the Unique ID of the building that covers the provided tile coordinates

Version
136.25
Parameters
PosX- Number (integer) - The location to check (X) - Required
PosY- Number (integer) - The location to check (Y) - Required
AllowFlooring- Boolean - Allow flooring in the check? - Defaults to false
AllowWalls- Boolean - Allow walls in the check? - Defaults to false
AllowFootprintTiles- Boolean - Allow the spawn/in/out/footprint tiles of the building in the check? - Defaults to false
Returns
Number - (integer) - The UID of the building sitting on coordinate provided (-1 if none)
Example
UID = ModBuilding.GetBuildingCoveringTile(50,80)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetBuildingsUIDsRequiringIngredientInArea()

int [] ModBuilding.GetBuildingsUIDsRequiringIngredientInArea ( string  IngredientString,
int  StartX,
int  StartY,
int  EndX,
int  EndY 
)

Get the unique IDs of buildings that require the specified ingredient in their recipe

Version
136.19
Parameters
IngredientString- String - The ingredient to search for - Required
StartX- Number (integer) - The location to start the search from (X) - Required
StartY- Number (integer) - The location to start the search from (Y) - Required
EndX- Number (integer) - The location to end the search at (X) - Required
EndY- Number (integer) - The location to end the search at (Y) - Required
Returns
Table (Number - integer) - An array of all the unique IDs of all the buildings in the area specified
Example
UIDs = ModBuilding.GetBuildingsUIDsRequiringIngredientInArea("Berries", 0,0, 50,80)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetFuelMaxCapacity()

float ModBuilding.GetFuelMaxCapacity ( int  UID)

Get the maximum Fuel capacity of a Building that allows it (e.g. TrainRefuellingStation, StationaryEngine)

Version
137.21
Parameters
UID- Number (integer) - the unique ID of the building object - Required
Returns
float - fuel capacity
Example
Amount = ModBuilding.GetFuelMaxCapacity(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetRotation()

int ModBuilding.GetRotation ( int  UID)

Get a building rotation

Version
137.21
Parameters
UID- Number (integer) - The unique ID of the building object - Required
Returns
int - The rotation of the building between 0 and 3 (or -1 if there's an error)
Example
NewRotation = ModBuilding.GetRotation(ObjID)
Note
This function will update the logic, not just the visuals so be careful using this doesn't position the building inside other buildings. Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsBuildingActuallyFlooring()

bool ModBuilding.IsBuildingActuallyFlooring ( int  UID)

Get if this building is actually of type flooring (Flooring is a type of building)

Version
135.20
Parameters
UID- Number (integer) - the unique ID of the building - Required
Returns
Boolean - True if the building is flooring. Returns false if item is not flooring OR object not found
Example
ModBuilding.IsBuildingActuallyFlooring(ObjId)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsBuildingSaveable()

bool ModBuilding.IsBuildingSaveable ( int  UID)

Get boolean of if building can be saved (is not a temp building)

Version
137.14.9
Parameters
UID- Number (integer) - The unique ID of the building object - Required
Returns
bool - whether or not the UID is a saveable building
Example
IsDragging = ModBuilding.IsBuildingSaveable(ObjID)
Note
. Can be used in functions: OnUpdate()

◆ RegisterForBuildingEditedCallback()

void ModBuilding.RegisterForBuildingEditedCallback ( int  BuildingUID,
DynValue  Callback 
)

Register for a building edited callback

Version
137.14.9
Parameters
BuildingUID- Number (integer) - The unique ID of the building object - Required
Callback- Function to be called when building is edited (EditType: Rotate, Move, Rename, Destroy)
Returns
none
Example
ModBuilding.RegisterForBuildingEditedCallback(BuildingUID, CallbackFunction)
CallbackFunction will be called like: CallbackFunction(BuildingUID, EditType, NewValue)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ RegisterForBuildingTypeSpawnedCallback()

void ModBuilding.RegisterForBuildingTypeSpawnedCallback ( string  NewTypeString,
DynValue  Callback 
)

Register for a callback when building of type spawned

Version
137.14.9
Parameters
ObjectType- String - The 'Type' of building
Callback- Function to be called when building is destroyed
Returns
none
Example
ModBuilding.RegisterForBuildingTypeSpawnedCallback(ObjectType, CallbackFunction)
CallbackFunction will be called like: CallbackFunction(BuildingUID, BuildingType, IsBlueprint, IsDragging)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ RegisterForNewBuildingInAreaCallback()

void ModBuilding.RegisterForNewBuildingInAreaCallback ( int  StartX,
int  StartY,
int  EndX,
int  EndY,
DynValue  Callback 
)

Register a callback for when a building is moved into or created within a specific area

Version
137.14.9
Parameters
int- StartX
int- StartY
int- EndX
int- EndY
CallbackFunction- Function - The function to callback to on event - Required
Returns
None
Example
ModBuilding.RegisterForNewBuildingInAreaCallback(StartX, StartY, EndX, EndY, NewBuildingInAreaCallback)
Callback return : function NewBuildingInAreaCallback(BuildingUID, IsBlueprint, IsDragging)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetBuildingName()

bool ModBuilding.SetBuildingName ( int  UID,
string  BuildingName 
)

Set a building name

Version
137.19
Parameters
UID- Number (integer) - The unique ID of the building object - Required
BuildingName- String - New name for the building - Required
Returns
Boolean - True if successfully set
Example
ModBuilding.SetBuildingName(ObjID, "MyCoolBuilding")
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetBuildingWalkable()

void ModBuilding.SetBuildingWalkable ( string  NewTypeString,
bool  CanBeWalkedThrough 
)

Set a building to be walked through (like a door/arch)

Version
136.23
Parameters
NewTypeString- String - The building type to search for - Required
CanBeWalkedThrough- Boolean - If this custom building can be walked through - Required
Returns
None
Example
ModBuilding.SetBuildingWalkable("FancyDoor", true)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetRotation()

bool ModBuilding.SetRotation ( int  UID,
int  Rotation 
)

Set a building rotation

Version
137.21
Parameters
UID- Number (integer) - The unique ID of the building object - Required
Rotation- int - New rotation for the building between 0 and 3 - Required
Returns
Boolean - True if successfully set
Example
ModBuilding.SetRotation(ObjID, 2)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ ShowBuildingAccessPoint()

void ModBuilding.ShowBuildingAccessPoint ( string  NewTypeString,
bool  EnableAccessPoint 
)

Set a building access point to be visible/invisible

Version
137.18
Parameters
NewTypeString- String - The building type to search for - Required
EnableAccessPoint- Boolean - If this custom building access point is enabled (visible) - Required
Returns
None
Example
ModBuilding.ShowBuildingAccessPoint("FancyDoor", true)
Note
Can be used in functions: Creation(), BeforeLoad()

◆ UnregisterForBuildingEditedCallback()

void ModBuilding.UnregisterForBuildingEditedCallback ( int  BuildingUID)

Unregister for a building edited callback

Version
137.14.9
Parameters
BuildingUID- Number (integer) - The unique ID of the building object - Required
Returns
none
Example
ModBuilding.UnregisterForBuildingEditedCallback(BuildingUID)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ UnregisterForNewBuildingInAreaCallback()

void ModBuilding.UnregisterForNewBuildingInAreaCallback ( int  StartX,
int  StartY,
int  EndX,
int  EndY 
)

Unregister a callback for when a building is moved into or created within a specific area

Version
137.14.9
Parameters
int- StartX
int- StartY
int- EndX
int- EndY
Returns
None
Example
ModBuilding.UnregisterForNewBuildingInAreaCallback(TileX, TileY)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

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