Autonauts Modding
ModBot Class Reference

Public Member Functions

int SpawnBot (string Name, int HeadLevel=0, int FrameLevel=0, int DriveLevel=0, int HeadVariant=0, int FrameVariant=0, int DriveVariant=0, int PositionX=0, int PositionY=0)
 
List< string > GetBotGroupNames ()
 
List< int > GetAllBotUIDs ()
 
List< int > GetAllBotUIDsInGroup (string GroupName)
 
void MoveTo (int UID, int x, int y)
 
void SetName (int UID, string NewName)
 
string GetName (int UID)
 
Table GetAllHeldObjectsUIDs (int UID)
 
string GetState (int UID)
 
bool GetIsRunningScript (int UID)
 
bool GetIsLearning (int UID)
 
Table GetParts (int UID)
 
void DropAllHeldObjects (int UID)
 
void DropAllUpgrades (int UID)
 
string GetScriptSavegameFormat (int UID, bool LogErrors=false)
 
bool SetScriptSavegameFormat (int UID, string JSON, bool LogErrors=false)
 
void StopScript (int UID)
 
void RechargeBot (int UID)
 
void StartScript (int UID)
 

Member Function Documentation

◆ DropAllHeldObjects()

void ModBot.DropAllHeldObjects ( int  UID)

Drop all objects in Bots hands

Version
137.14
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
None
Example
ModBot.DropAllHeldObjects(3428)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ DropAllUpgrades()

void ModBot.DropAllUpgrades ( int  UID)

Drop all upgrades from Bot

Version
137.14
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
None
Example
ModBot.DropAllUpgrades(3428)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetAllBotUIDs()

List<int> ModBot.GetAllBotUIDs ( )

Get a list of all the Bot unique IDs

Version
135.17
Parameters
None
Returns
Table (integer) - A table of all the UIDs of Bots
Example
ModBot.GetAllBotUIDs()
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetAllBotUIDsInGroup()

List<int> ModBot.GetAllBotUIDsInGroup ( string  GroupName)

Get a list of all the Bot unique IDs from a specific Group

Version
135.17
Parameters
GroupName- String - The string name of the group - Required
Returns
Table (integer) - A table of all the UIDs of Bots from the specified group
Example
ModBot.GetAllBotUIDsInGroup()
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetAllHeldObjectsUIDs()

Table ModBot.GetAllHeldObjectsUIDs ( int  UID)

Get all the held object unique IDs that the Bot is holding

Version
135.19
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
Table (Number Array) - The unique IDs of the objects being held (returns table with first entry as -1 if none found)
Example
ModBot.GetAllHeldObjectsUIDs(345)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetBotGroupNames()

List<string> ModBot.GetBotGroupNames ( )

Get a list of all the Bot groups names

Version
135.6
Parameters
None
Returns
Table (String)
Example
ModBot.GetBotGroupNames()
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetIsLearning()

bool ModBot.GetIsLearning ( int  UID)

Is the Bot learning currently (from provided unique ID)

Version
137.17
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
Boolean - True if learning
Example
State = ModBot.GetIsLearning(6578)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetIsRunningScript()

bool ModBot.GetIsRunningScript ( int  UID)

Is the Bot running a script (from provided unique ID)

Version
137.17
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
Boolean - True if running a script
Example
State = ModBot.GetIsRunningScript(6578)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetName()

string ModBot.GetName ( int  UID)

Get a Bot's name

Version
136.22
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
String - Name of the desired Bot
Example
Name = ModBot.GetName(3428)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetParts()

Table ModBot.GetParts ( int  UID)

Get a given Bot's parts (from provided unique ID)

Version
135.20
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
Table (Number) - The Bot's parts [1]=Head,[2]=Frame,[3]=Drive (returns table with first entry as -1 if no bot found)
Example
Parts = ModBot.GetParts(6578)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ GetScriptSavegameFormat()

string ModBot.GetScriptSavegameFormat ( int  UID,
bool  LogErrors = false 
)

Get Bot script data as a raw JSON string (savegame fragment)

Version
137.14.9
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
LogErrors- Boolean - If True, output any errors to ModLog.txt - Defaults to false
Returns
JSON (string)
Example
json = ModBot.GetScriptSavegameFormat(1234)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()
Warning
These functions use raw JSON savegame values to read and write bot scripts. To avoid bugs and visual glitches, please maintain all attribute values and residual teaching data copied from a working bot script. Below is a rough description of each instruction's attributes:
  • **Type** - Instruction type
  • **ArgName** - General purpose argument
  • **Line** - Number (used for debuging, safe to ignore or set to -1)
  • **OT** - Object type
  • **UID** - Object UID
  • **X**,Y - World coordinates
  • **V1** - Variable 1
  • **V2** - Variable 2
  • **A** - Action
  • **R** - Action requirements
  • **AT** - Mouse action type (what the player pressed when they taught the action)
  • **AOT** - Action object type (the type of object used for this action)
  • **Children** - List of instructions called by Repeats and Ifs
  • **Children2** - List of instructions called by IfElse

◆ GetState()

string ModBot.GetState ( int  UID)

Get a given Bot's state (from provided unique ID)

Version
135.19
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Returns
String - The Bot's state
Example
State = ModBot.GetState(6578)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ MoveTo()

void ModBot.MoveTo ( int  UID,
int  x,
int  y 
)

Move a Bot to another location

Version
135.6
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
x- Number (integer) - The location to move to in tile coordinates
y- Number (integer) - The location to move to in tile coordinates
Returns
None
Example
ModBot.MoveTo(3428, 86, 21)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ RechargeBot()

void ModBot.RechargeBot ( int  UID)

Recharge Bot

Version
137.14.9
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Example
ModBot.RechargeBot(1234)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetName()

void ModBot.SetName ( int  UID,
string  NewName 
)

Set a Bot's name

Version
135.6
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
NewName- String - Name for the desired Bot to be set
Returns
None
Example
ModBot.SetName(3428, "Gary")
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ SetScriptSavegameFormat()

bool ModBot.SetScriptSavegameFormat ( int  UID,
string  JSON,
bool  LogErrors = false 
)

Set Bot data from a raw JSON string (savegame fragment)

Version
137.14.9
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
JSON- String (JSON) - Raw script data in JSON format
LogErrors- Boolean - If True, output any errors to ModLog.txt - Defaults to false
Returns
Boolean - True if Bot script set successfully
Example
-- Create a wait instruction based on a variable...
seconds = 60
ModBot.SetScriptSavegameFormat(1234,'[{"Type":"InstructionWait","ArgName":"","Line":-1,"OT":"Plot","UID":0,"X":0,"Y":0,"V1":"'..seconds..'","V2":"","A":"MoveTo","R":"","AT":0,"AOT":"Total"}]')
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()
Warning
Recommend programming a bot first and using GetScriptSavegameFormat to create a JSON template. Keep it simple and take care to avoid bot script corruption (double check any variables you want to plug into the JSON are valid before you call this).

◆ SpawnBot()

int ModBot.SpawnBot ( string  Name,
int  HeadLevel = 0,
int  FrameLevel = 0,
int  DriveLevel = 0,
int  HeadVariant = 0,
int  FrameVariant = 0,
int  DriveVariant = 0,
int  PositionX = 0,
int  PositionY = 0 
)

Spawn a Bot

Version
136.19
Parameters
Name- String - The Bot's name - Required
HeadLevel- Number (integer) - The Mark (level) of the current Bot's Head (0-3 inc.) - Defaults to 0
FrameLevel- Number (integer) - The Mark (level) of the current Bot's Frame (0-3 inc.) - Defaults to 0
DriveLevel- Number (integer) - The Mark (level) of the current Bot's Drive (0-3 inc.) - Defaults to 0
HeadVariant- Number (integer) - The Variant of the current Bot's Head (0-4 inc.) - Defaults to 0
FrameVariant- Number (integer) - The Variant of the current Bot's Frame (0-4 inc.) - Defaults to 0
DriveVariant- Number (integer) - The Variant of the current Bot's Drive (0-4 inc.) - Defaults to 0
PositionX- Number (integer) - X coordinate of the bot on the map
PositionY- Number (integer) - Y coordinate of the bot on the map
Returns
Number (integer) - Bot's Unique ID (Returns -1 if failed)
Example
ModBot.SpawnBot("Gary")
ModBot.SpawnBot("Aaron", 0,1,2, 0,2,2, 20,20)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ StartScript()

void ModBot.StartScript ( int  UID)

Start Bot script

Version
137.14.9
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Example
ModBot.StartScript(1234)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

◆ StopScript()

void ModBot.StopScript ( int  UID)

Bot script will stop after the current action completes

Version
137.14.9
Parameters
UID- Number (integer) - The unique identifier for the desired Bot
Example
ModBot.StopScript(1234)
Note
Can be used in functions: AfterLoad(), AfterLoad_CreatedWorld(), AfterLoad_LoadedWorld(), OnUpdate()

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