lstwoMODS Core • Using lstwoMODS

Using Macros

Macros are a way to create hotkeys, chat commands, or other procedures that use the features of mods. They can be simple hotkeys to set one value in a mod, or more complicated procedures.

They support expressions, nesting macros and more.

Creating Macros

You can create a new macro through a couple different ways.

You can click the + New Macro button on the macros panel to create a new one. You can also right click most mod elements to add them to a macro or a new hotkey macro.

Macro Groups

All macros are within a macro group and each macro group is stored in a separate file which you can use to share macros. You can create a new macro group at the top of the macros panel.

Advanced Mode

Turning on advanced mode allows you to use more advanced macro features, such as expressions, named step outputs, etc. Those features are covered further down the page.

Macro Triggers

Every macro has a trigger. By default that trigger is Manual. A trigger defines when the macro should run. lstwoMODS Core has a few built in macro triggers but other mods may add more. Check their respective documentation for more info.

Manual

The manual trigger will only run when the run button is pressed on the macro.

Called by Macro

The called by macro trigger allows you to set parameters to run the macro which will have to be set by other macros running this one using the Run Macro step. Think of this one as turning your macro into a function / method.

Hotkey

The hotkey trigger will allow your macro to be run when certain keys are pressed. It also has a toggle mode where on the first press it runs the on list, on the second the off, and so on, switching between the two.

Interval

This trigger calls your macro every x second (be careful with this one)

Built-in Steps

There are a few built in macro steps, some will be explained some i will just add to this list:

  • Expression
  • For Each (item in list)
  • If
  • Log
  • Repeat (N times)
  • Return
  • Run Macro
  • Switch
  • Variables
    • Get
    • Set
    • Load from disk
    • Save to disk
  • Wait

Expression

The expression step returns the value given to it. With advanced mode on you can use it to name a variable that can be used in this macro run. You do not need this step to evaluate expressions this is just to keep a variable.

Log

Logs something to the console, only really useful if you have the BepInEx console visible to debug your macros.

Return

Returns a value from this macro and stops execution. Can be used to stop a macro, or to give an output value to another macro that calls it using the Run Macro step.

Variables

Each variable has a key, value and scope. The scope defines which macros can access it, either this one, all in the group, or all no matter which group.

The save to disk ones are separate however and not affected by scope.


Expressions

Expressions are a way to dynamically evaluate values. They are written in C# expression syntax. You can do a lot of things using expressions here are a few example ones:

num * 2

Multiplies a value named num from a previous step by 2

rand(1, 17)

Picks a random number between 1 and 17

pick("a", "b", "c")

Picks randomly between a, b and c