Autonauts Modding
ModBase Class Reference

Public Member Functions

void SetSteamWorkshopDetails (string Title="", string Description="", string[] Tags=null, string ContentImage="")
 
int SpawnItem (string Item="Nothing", int NewX=0, int NewY=0, bool DoOnce=false, bool Instant=false, bool ForceBP=false)
 
int SpawnLiquid (string LiquidItem, string FillableItem="ToolBucket", int NewX=0, int NewY=0)
 
void DisableSafety (bool Disable)
 
void ExposeVariable (string UniqueName, DynValue DefaultValue, DynValue Callback, DynValue Min, DynValue Max)
 
void ExposeVariableList (string UniqueName, DynValue[] DefaultOptions, int DefaultSelectedOption, DynValue Callback)
 
void ExposeKeybinding (string UniqueName, int Key, DynValue Callback)
 
void RegisterForInputPress (DynValue Callback)
 
void RegisterForInputMouseButtonDown (DynValue Callback)
 
DynValue GetExposedVariable (string UniqueName)
 
bool IsNightTime ()
 
string GetGameState ()
 
string GetGameVersion ()
 
int GetGameVersionPatch ()
 
int GetGameVersionMinor ()
 
int GetGameVersionMajor ()
 
bool IsGameVersionGreaterThanEqualTo (string DesiredVersion)
 
bool IsRaining ()
 
bool ClassAndMethodExist (string ClassName, string MethodName)
 
void RegisterForItemTypeSpawnedCallback (string NewTypeString, DynValue Callback)
 
void UnregisterForItemTypeSpawnedCallback (string NewTypeString)
 

Member Function Documentation

◆ ClassAndMethodExist()

bool ModBase.ClassAndMethodExist ( string  ClassName,
string  MethodName 
)

See if a mod method exists.

Version
137.14.9
Parameters
string- ClassName
string- MethodName
Returns
Boolean - true if class and method exist
Example
ModBase.ClassAndMethodExist('ModBuilding','SomeBuildingFunction')
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ DisableSafety()

void ModBase.DisableSafety ( bool  Disable)

Disable the safety functionality - Stops flowers, birds, trees etc. from always spawning to a safe amount

Version
134.30
Parameters
Disable- Boolean - True to disable safety, false to keep it enabled - Required
Returns
None
Example
ModBase.DisableSafety(true)
Note
Can be used in functions: BeforeLoad()

◆ ExposeKeybinding()

void ModBase.ExposeKeybinding ( string  UniqueName,
int  Key,
DynValue  Callback 
)

Expose a defined keybinding - Allowing a user to define a key to your expressed function callback

Version
134.31
Parameters
UniqueName- String - The unique and corresponding name of the Exposed variable - Required
Key- Number (integer) - The unique key to choose (from 1-10 inc.) that will be found to the function callback provided - Required
Callback- Function - The function to callback when the keypress is made - Required
Returns
None
Example
ModBase.ExposeKeybinding("Explosion", 4, ExposedKeyCallback)
(Example Lua)
Note
Can be used in functions: Expose()

◆ ExposeVariable()

void ModBase.ExposeVariable ( string  UniqueName,
DynValue  DefaultValue,
DynValue  Callback,
DynValue  Min,
DynValue  Max 
)

Expose a variable - Allowing a user to define the exact 'amount' of the 'item' and calls back to the expressed function.

Version
134.31
Parameters
UniqueName- String - The unique and corresponding name of the Exposed variable - Required
DefaultValue- Number/Boolean - The starting (default) value of your Exposed variable - Required
Callback- Function - The function to callback when the value is changed - Required
Min- Number - The minimum allowed value of your Exposed variable - Required for Numbers
Max- Number - The maximum allowed value of your Exposed variable - Required for Numbers
Returns
None
Example
ModBase.ExposeVariable("Speed", Speed, ExposedCallback)
(Example Lua)
Note
Can be used in functions: Expose()

◆ ExposeVariableList()

void ModBase.ExposeVariableList ( string  UniqueName,
DynValue[]  DefaultOptions,
int  DefaultSelectedOption,
DynValue  Callback 
)

Expose a variable list - Allowing a user to define an option from dropdown and calls back to the expressed function.

Version
136.23
Parameters
UniqueName- String - The unique and corresponding name of the Exposed variable - Required
DefaultOptions- String Array - The starting (default) value of your Exposed variable - Required
DefaultSelectedOption- Number (int) - The starting (default) option of your Exposed variable - Required
Callback- Function - The function to callback when the value is changed - Required
Returns
None
Example
ModBase.ExposeVariableList("Colours", {"Red","Blue","Yellow"}, 0, ExposedCallback)
On callback the value with be the index into your array e.g. 1 (Which equals "Blue")
Note
Can be used in functions: Expose()

◆ GetExposedVariable()

DynValue ModBase.GetExposedVariable ( string  UniqueName)

Get an Exposed variable value

Version
134.26
Parameters
UniqueName- String - The unique and corresponding name of the Exposed variable - Required
Returns
Dynamic - returns variable contents (of what was asked for)
Example
ModBase.GetExposedVariable("Speed")
(Example Lua)
Note
Can be used in functions: Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetGameState()

string ModBase.GetGameState ( )

Get the current state of the game

Version
134.31
Parameters
None
Returns
String - State as a string (e.g. "Normal" or "Edit" or "MainMenu")
Example
ModBase.GetGameState()
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetGameVersion()

string ModBase.GetGameVersion ( )

Get the version of the game

Version
136.22
Parameters
None
Returns
String - Version as a string (e.g. "134.31")
Example
ModBase.GetGameVersion()
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetGameVersionMajor()

int ModBase.GetGameVersionMajor ( )

Get the MAJOR version of the game

Version
136.22
Parameters
None
Returns
Number - Major part of Version as a number (e.g. returns '136' if version is "136.22")
Example
ModBase.GetGameVersionMajor()
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetGameVersionMinor()

int ModBase.GetGameVersionMinor ( )

Get the MINOR version of the game

Version
136.22
Parameters
None
Returns
Number - Minor part of Version as a number (e.g. returns '22' if version is "136.22")
Example
ModBase.GetGameVersionMinor()
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetGameVersionPatch()

int ModBase.GetGameVersionPatch ( )

Get the PATCH version of the game

Version
136.22
Parameters
None
Returns
Number - Patch part of Version as a number (e.g. returns '3' if version is "136.22.3")(Returns 0 if no patch number)
Example
ModBase.GetGameVersionPatch()
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsGameVersionGreaterThanEqualTo()

bool ModBase.IsGameVersionGreaterThanEqualTo ( string  DesiredVersion)

GIs the current version above the specified version of the game

Version
136.22
Parameters
DesiredVersion- String - The Version number e.g. "136.22.4"
Returns
Boolean - True if version of game is above or equal to passed in version
Example
ModBase.IsGameVersionGreaterThanEqualTo("136.22.4")
Note
Can be used in functions: Creation(), Expose(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsNightTime()

bool ModBase.IsNightTime ( )

Get if the game is currently at night

Version
134.31
Parameters
None
Returns
Boolean - true for night time, false for day time
Example
ModBase.GetGameState()
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ IsRaining()

bool ModBase.IsRaining ( )

Get if it's currently raining in game

Version
136.19
Parameters
None
Returns
Boolean - true for raining
Example
ModBase.IsRaining()
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ RegisterForInputMouseButtonDown()

void ModBase.RegisterForInputMouseButtonDown ( DynValue  Callback)

Register for input callbacks (for On Mouse Button Down)

Version
135.17
Parameters
Callback- Function - The function to callback when any mouse button down event occurs - Required
Returns
None
Example
ModBase.RegisterForInputMouseButtonDown(InputCallback)
(Example Lua)
Note
Can be used in functions: Expose()

◆ RegisterForInputPress()

void ModBase.RegisterForInputPress ( DynValue  Callback)

Register for input callbacks (for On KeyPress)

Version
134.31
Parameters
Callback- Function - The function to callback when any keypress is made - Required
Returns
None
Example
ModBase.RegisterForInputPress(InputCallback)
(Example Lua)
Note
Can be used in functions: Expose()

◆ RegisterForItemTypeSpawnedCallback()

void ModBase.RegisterForItemTypeSpawnedCallback ( string  NewTypeString,
DynValue  Callback 
)

Register for a callback when item of type spawned

Version
137.14.9
Parameters
ObjectType- String - The 'Type' of object
Callback- Function to be called when building is destroyed
Returns
none
Example
ModBase.RegisterForItemTypeSpawnedCallback(ObjectType, CallbackFunction)
CallbackFunction will be called like: CallbackFunction(ObjectUID, ObjectType, TileX, TileY)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetSteamWorkshopDetails()

void ModBase.SetSteamWorkshopDetails ( string  Title = "",
string  Description = "",
string[]  Tags = null,
string  ContentImage = "" 
)

Setup information for Mod and Steam workshop

Version
134.19
Parameters
Title- String - Title of the Mod - Required
Description- String - Description about the Mod - Required
Tags- String Array - Each of the tags used in Steam Workshop - Required
ContentImage- String - Image used to show the Mod (in game and in Steam) - Required
Returns
None
Example
ModBase.SetSteamWorkshopDetails("MyFirstMod", "Description", {"tag1", "tag2"}, "ThisIsTheLogo.png")
(Example Lua)
Note
Can be used in functions: SteamDetails()

◆ SpawnItem()

int ModBase.SpawnItem ( string  Item = "Nothing",
int  NewX = 0,
int  NewY = 0,
bool  DoOnce = false,
bool  Instant = false,
bool  ForceBP = false 
)

Spawn an item in game

Version
134.24
Parameters
Item- String - The item to spawn - Required
NewX- Number (integer) - X Position in tile coordinates - Required
NewY- Number (integer) - Y Position in tile coordinates - Required
DoOnce- Boolean - If this should only spawn once, or every load (do not use in a large loop) - Defaults to false
Instant- Boolean - If the building should be forced instantly built - Defaults to false
ForceBP- Boolean - If the building should be forced to blueprint stage - Defaults to false
Returns
Number (integer) - The Unique ID of object spawned (returns -1 if failed)
Example
ModBase.SpawnItem("Berries", 0, 0)
ModBase.SpawnItem("CustomFoodType", 10, 10)
ModBase.SpawnItem("Berries", 0, 0, true)
ModBase.SpawnItem("Workshop", 0, 0, false, true, false)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SpawnLiquid()

int ModBase.SpawnLiquid ( string  LiquidItem,
string  FillableItem = "ToolBucket",
int  NewX = 0,
int  NewY = 0 
)

Spawn a liquid item in a bucket in game

Version
136.26
Parameters
LiquidItem- String - The item to spawn (Must be a liquid) - Required
FillableItem- String - The item to spawn liquid in (Must be a fillable object) - Defaults to "ToolBucket"
NewX- Number (integer) - X Position in tile coordinates - Defaults to 0
NewY- Number (integer) - Y Position in tile coordinates - Defaults to 0
Returns
Number (integer) - The Unique ID of object spawned (returns -1 if failed)
Example
ModBase.SpawnLiquid("Milk", "ToolBucket", 0, 0)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ UnregisterForItemTypeSpawnedCallback()

void ModBase.UnregisterForItemTypeSpawnedCallback ( string  NewTypeString)

Unregister for all "Item type spawned" related to an item type

Version
137.14.9
Parameters
TypeString- string - the type we no longer watch for
Returns
none
Example
ModBase.UnregisterForItemTypeSpawnedCallback(TypeString)
Note
Can be used in functions: Creation(), BeforeLoad(), AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

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