Instructions/Set to Component: Difference between revisions

From Desynced Wiki
No edit summary
m (→‎Uses: Fix formatting of group example)
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
==== Uses ====
==== Uses ====


Can typically be used to set a Turret, Repair Component, Deconstructor or Miner to a specific target, but for Radar, it is probably advisable to use the [[Instructions/Radar|Radar]] instruction instead.
Can typically be used to set a Turret, Repair Component, Deconstructor or Miner to a specific target, but for Radar, it is probably advisable to use the [[Instructions/Radar|Radar]] instruction instead. Can also be used to set the production recipe for factory buildings.


0 and 1 are both treated as index 1.
Indexes 0 and 1 are both treated as index 1.


A component seldom has multiple input registers, but for the few that exist, any number from 1 - n can be used to specify what index to write data to.  
A component seldom has multiple input registers, but for the few that exist, any number from 1 - n can be used to specify what index to write data to.  
Line 15: Line 15:


In its most dynamic usage, it can be used to write directly to the parameters from another Behavior Controller, which can have a theoretically infinite amount of parameters.
In its most dynamic usage, it can be used to write directly to the parameters from another Behavior Controller, which can have a theoretically infinite amount of parameters.
The third argument (Group/Index) specifies the 1-based index of the component to set from the list of components when filtered by the Component/Index argument. 
Take for a building with the components below:
[[File:Set to component group example.png]]
In this example setting Component/Index to an Assembler the possible values for Group/Index are only 1. If you set Component/Index to Fabricator the possible values for Group/Index are also only 1 as there is only one Fabricator slotted in this building.


==== Similar Instructions ====
==== Similar Instructions ====

Latest revision as of 03:36, 2 January 2024


Set to Component
     
     Writes a value into a component register
Lua ID set_comp_reg
Category Math
Icon Set Component Reg.png
Argument One: Type Input
Argument One: Name Value
Argument One: Description Value to set
Argument One: Data Type any
Argument Two: Type Input
Argument Two: Name To
Argument Two: Description Component and register number to set
Argument Two: Data Type comp_num
Argument Three: Type Input
Argument Three: Name Component Index
Argument Three: Description Component index if multiple are equipped
Argument Three: Data Type num



Description[edit | edit source]

Used to set a value to a component register with a specified index.

Uses[edit | edit source]

Can typically be used to set a Turret, Repair Component, Deconstructor or Miner to a specific target, but for Radar, it is probably advisable to use the Radar instruction instead. Can also be used to set the production recipe for factory buildings.

Indexes 0 and 1 are both treated as index 1.

A component seldom has multiple input registers, but for the few that exist, any number from 1 - n can be used to specify what index to write data to.

In its most dynamic usage, it can be used to write directly to the parameters from another Behavior Controller, which can have a theoretically infinite amount of parameters.

The third argument (Group/Index) specifies the 1-based index of the component to set from the list of components when filtered by the Component/Index argument.

Take for a building with the components below:

In this example setting Component/Index to an Assembler the possible values for Group/Index are only 1. If you set Component/Index to Fabricator the possible values for Group/Index are also only 1 as there is only one Fabricator slotted in this building.

Similar Instructions[edit | edit source]

Get from Component, Radar, Mine