Behavior Programming

From Desynced Wiki
Revision as of 12:27, 19 August 2023 by Johan (talk | contribs)

Taking volunteers to write short guides on putting together a few simple behaviors.

Try not to add layers of complexity - creating a guide for something that can be improved upon will allow the student to reinforce the existing knowledge you have given them.

We need roughly 5 good examples

Good subjects may be:

Utilizing Parameters for passing information into and out of a behavior

Registers, parameters and variables are a key element to the game and especially so for making any good use of behaviors. In short, all three are essentially one and the same: a place to store and recall information.

  • A register is the inputs and outputs of components. When you assign a Fabricator to produce Metal Bars, you are interacting with the first register. The Fabricator then assigns the second register to Metal Ore.
    • Another example is the visual register on the unit registers interface below the component registers.
  • A parameter is created from within a behavior - on the top left of the editor, you will see a - and a + sign. You can create as many or as few as you deem necessary. The main benefit of doing so is so that you can pass information into and out of a behavior without using any unit registers.
  • A variable is exclusively for use inside a behavior and it serves as a quicker way of creating information storage that is visually recognizable at a glance. If you have any instruction with an output, you can create a new variable - they are alphanumeric, so the first is A, then B, etc.
Components and their corresponding instruction analogs

One objective of the game is to enable the user to choose whether or not they wish to interact with behaviors. It isn't strictly necessary to enjoy or progress through the game to do so, but you're here now so you've made your choice. The game provides analogs of components in the form of instructions within behaviors. One of these is the Portable Radar and another is the Signal Reader.

The two are often used in combination - for example:

  • You can find a Construction using a Portable Radar with the filter:construction. The result can be linked into a Signal Reader to automate getting the signal.
  • A building under construction has a requirement of materials to be delivered. What is useful in this case is that it stores required materials the signal register. Using a Signal Reader or its analog, the Read Signal instruction, you can obtain the stored signal value.

For this part you will only need: a Portable Radar and a Behavior Controller.

  1. Find the Radar instruction and connect it to the starting node
  2. Input a filter for Construction into the Radar instruction - it should be under the Information section
  3. Set the Result parameter to a new variable:A
  4. Find the Read Signal instruction and attach it to the top node of the Radar instruction
  5. Input the result variable:A into the Unit parameter of Read Signal
  6. Write the Result into a new variable:B

What we have now is a behavior that finds a construction in range and acquires its signal which is an item required for the construction to be completed. What we must do next once we have this information is to include the acquisition of those items

  1. Create a parameter within the behavior editor ( - and + up the top left corner) and click on its name and label it as "Home Location"

Obtaining and utilizing a Signal Reader or Read Signal for item delivery or mining

Using Compare Number to determine outcomes