Instructions: Difference between revisions

From Desynced Wiki
No edit summary
No edit summary
Line 2: Line 2:


=== Unit ===
=== Unit ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 9: Line 8:
|format=table
|format=table
}}
}}
</div>
=== Move ===
=== Move ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 18: Line 15:
|format=table
|format=table
}}
}}
</div>
=== Component ===
=== Component ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 27: Line 22:
|format=table
|format=table
}}
}}
</div>
=== Flow ===
=== Flow ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 36: Line 29:
|format=table
|format=table
}}
}}
</div>
=== Math ===
=== Math ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 45: Line 36:
|format=table
|format=table
}}
}}
</div>
=== Global ===
=== Global ===
<div class="mw-collapsible mw-collapsed" style="overflow:auto;">
{{#cargo_query:
{{#cargo_query:
tables=instruction
tables=instruction
Line 54: Line 43:
|format=table
|format=table
}}
}}
</div>


====== Compare Number ======
====== Compare Number ======

Revision as of 03:13, 26 August 2023

An instruction is a node within behavior programming. Each instruction is composed of .LUA code.

Unit

name description
Check Altitude Divert program depending on location of a unit or coordinate
Check Battery Checks the Battery level of a unit
Check Blightness Divert program depending on location of a unit or coordinate
Check Grid Efficiency Checks the Efficiency of the logistics network the unit is on
Check Health Check a unit&#039;s health
Clear All Links Clear all register links on this unit
Clear Link Clear register link
Connect Connects the Unit to the Logistics Network
Count Items Counts the number of the passed item contained in the unit&#039;s inventory
Count Slots Returns the number of slots in this unit of the given type
Disable Transport Route Disable Unit to deliver on transport route
Disconnect Disconnects the Unit from the Logistics Network
Drop Off Items Drop off items at a unit or location
Enable Transport Route Enable Unit to deliver on transport route
Equip Component Equips a component if it exists
First Item Reads the first item in your inventory
Fix Item Slots Fix all storage slots or a specific item slot index
Get Active Order Gets the source, target and amount data from the current active order
Get Closest Entity Gets the closest visible entity matching a filter
Get Closest Unit Gets the closest visible unit matching a filter
Get First Locked Id Gets the first item where the locked slot exists but there is no item in it
Get Inventory Item Reads the item contained in the specified slot index
Get Item Info Gets information on an item
Get Unit Info Gets information on a unit
Get Unit Power Info Gets power information on a unit
Get Unit Type Get the frame type of the unit
Inventory Total Returns the total contained in inventory
Is Docked Check if a unit is docked and get its garage
Is Equipped Check if a specific component has been equipped
Is Fixed Check if a specific item slot index is fixed
Is Inside Logistics Network Checks if a unit or coordinates is in the logistics network
Is Moving Checks the movement state of a unit
Is Same Grid Checks if two units or coordinates are in the same logistics network
Is Unit A Get the frame type of the unit
Lock Itemslot Lock a specific itemslot index, a range of slot index via coord, or all storage slots
Loop Nearby Resources Scans for nearby resources in power field range
Match Filters the passed unit
Order to Shared Storage Request Inventory to be sent to nearest shared storage with corresponding locked slots
Order Transfer To Transfers an Item to another Unit
Package All Tries to pack all packable units into items
Pick Up Items Picks up items from a unit
Read Radio Reads the Radio signal on a specified band
Read Signal Reads the Signal register of another unit
Request Item Requests an item if it doesn&#039;t exist in the inventory
Request Wait Requests up to a specified amount of an item and waits until that amount exists in inventory
Set Link Set register link
Solve Explorable Attempt to solve an explorable
Sort Storage Sorts Storage Containers on Unit
Switch Filters the passed unit or item
Turn Off Shuts down the power of the Unit
Turn On Turns on the power of the Unit
Unequip Component Unequips a component if it exists
Unfix Item Slots Unfix all inventory slots or a specific item slot index
Unlock Itemslot Unlock a specific itemslot index, a range of slot index via coord, or all storage slots
Unpackage All Tries to unpack all packaged items

Move

name description
*Move Unit (Range)* *DEPRECATED* Use Move Unit
Attack Move Moves towards a location stopping to attack any enemies encountered
Is Passable Checks whether a location is passable
Move Away (Range) Moves out of range of another unit, the number value of the target specifies the range
Move East Moves towards a tile East of the current location at the specified distance
Move North Moves towards a tile North of the current location at the specified distance
Move South Moves towards a tile South of the current location at the specified distance
Move Unit Moves to another unit or within a range of another unit
Move Unit (Async)* *DEPRECATED* Use Move Unit
Move West Moves towards a tile West of the current location at the specified distance
Scout Moves in a scouting pattern around the factions home location
Scout Range Moves in a random direction a specified amount Optionally pass a coordinate to give some directionality
Stop Unit Stop movement and abort what is currently controlling the unit&#039;s movement

Component

name description
Deploys held unit Deploys held unit at location specified or current location
Mine Mines a single resource
Radar Scan for the closest unit that matches the filters
Set Signpost Set the signpost to specific text

Flow

name description
*Loop Signal* *DEPRECATED* Use Loop Signal (Match) instead
Break Break out of a loop
call
Call Call a subroutine
Clear Research Clears a research from queue, or entire queue if no tech passed
Compare Entity Compares Entities
Compare Item Compares Item or Unit type
Compare Register Compares Registers for equality
Compare Unit Compares Units
Data type switch Switch based on type of value
Exit Stops execution of the behavior
Get Max Stack Returns the amount an item can stack to
Get Research Returns the first active research tech
Get Research Requirement Returns the research required (if needed)
Have Item Checks if you have at least a specified amount of an item
Is a Compares if an item of unit is of a specific type
Is Empty Checks a value if it is empty
Is Unlocked Checks whether a faction has an id unlocked
Jump Jumps execution to label with the same label id
Label Labels can be jumped to from anywhere in a behavior
Lock Run one instruction at a time
Loop Components Loops through Components
Loop Entities (Range) Performs code for all entities in visibility range of the unit
Loop Inventory Slots Loops through Inventory
Loop Number Performs code for all numbers in a range
Loop Producers Gets all producers for a production with their production time
Loop Recipe Ingredients Loops through Ingredients
Loop Research Performs code for all researchable tech
Loop Research Ingredients Loops through Ingredients
Loop Research Unlocks Performs code for all unlocks for a researchable tech
Loop Signal (Match) Loops through all units with a signal of similar type
Loop Units (Range) Performs code for all units in visibility range of the unit
Restart Restart execution of the behavior
Select Nearest Branches based on which unit is closer, optional branches for closer unit
Set Research Returns the first active research tech
Unit Type Divert program depending on unit type
Unlock Run as many instructions as possible. Use wait instructions to throttle execution.
Wait Ticks Pauses execution of the behavior until 1 or more ticks later (5 ticks=1 second)

Math

name description
Add Adds a number or coordinate to another number or coordinate
Check space for item Checks if free space is available for an item and amount
Combine Coordinate Returns a coordinate made from x and y values
Combine Register Combine to make a register from separate parameters
Compare Number Divert program depending on number of Value and Compare
Copy Copy a value to a frame register, parameter or variable
Divide Divides a number or coordinate from another number or coordinate
Get Battery Gets the value of the Battery level as a percent
Get Entity At Gets the best matching entity at a coordinate
Get Equipped Num Returns how many of a component are equipped
Get from Component Reads a value from a component register
Get Grid Efficiency Gets the value of the Grid Efficiency as a percent
Get Health Gets a unit&#039;s health as a percentage, current remaining and max amount
Get Resource Num Gets the amount of resource
Get Self Gets the value of the Unit executing the behavior
Get Shield Get a unit&#039;s shield as a percentage, current remaining and max amount
Get space for item Returns how many of the input item can fit in the inventory
Get Unit At Gets the best matching unit at a coordinate
Is Working Checks whether a particular component is currently working
Modulo Get the remainder of a division
Multiply Multiplies a number or coordinate from another number or coordinate
Random Coordinate Returns a random coordinate from a location within a specified range
Random Number Returns a random number between a min and max value
Separate Coordinate Split a coordinate into x and y values
Separate Register Split a register into separate parameters
Set Number Sets the numerical/coordinate part of a value
Set to Component Writes a value into a component register
Subtract Subtracts a number or coordinate from another number or coordinate

Global

name description
Abort Construction Abort an owned construction
Can Produce Returns if a unit can produce an item
DebugPrint Debug print to log
Distance Returns distance to a unit
Faction Item Amount Counts the number of the passed item in your logistics network
Get Home Gets the factions home unit
Get Ingredients Returns the ingredients required to produce an item
Get Location Gets location of a seen unit
Get Season Divert program depending on season
Get Stability Gets the current world stability
Get Trust Gets the trust level of the unit towards you
Get Type Gets the type from an item or unit
Is Day/Night Divert program depending time of day
Land Tells a satellite that has been launched to land
Launch Launches a satellite if equipped on an AMAC
Lookat Turns the unit to look at a unit or a coordinate
Notify Triggers a faction notification
Percent Gives you the percent that value is of Max Value
Pings a Unit Plays the Ping effect and notifies other players
Place Construction Places a construction site for a specific structure
Produce Registered Unit Sets a production component to produce a blueprint
Produce Unit Sets a production component to produce a blueprint
Read Key Attempts to read the internal key of the unit
Remap Remaps a value between two ranges
Resource Type Gets the resource type from an resource node
Compare Number

The "Compare Number" Component takes in a value and compares that value against another. This can be used to compare two numbers as intended or used as an if statement. To use this node as an if statement you can compare a value of 0/1 against 0 this will allow you to use the "If Larger" and "If Smaller" as true or false to determine a conditional statement.

Comparing a variable against the value of 100. This allows for the node to be used as a conditional statement.

Distance

The "Distance" component takes a location based input (unit world location) and stores the distance from the that input to the unit your script is being run on in the result. This can be used identify how far one unit is away from another.

Using the signal register as an input (which is set to a unit world location) and storing the distance value as a variable.

Get Home

The "Get Home" component gets the factions Home Unit and writes the result to a Unit Register or a Variable. The result can then be referenced later as the home location.

Writing the Home value to the Signal Register

List of Nodes and how they can be used [Community Member added - May not be accurate or contain all possible use cases] -- WIP