Integrated Dynamics - On the Dynamics of Integration

Global functions

When writing JavaScript code, you can make use of the global idContext variable to access all Integrated Dynamics operators as functions through the ops field. This allows you to make use of built-in operators when creating new ones.

For example, you can write an Item filter that checks if an item is stackable and if it has a stack size of at least 16, as shown below.

To know what the name is of the operator you want to execute, you can look at their global name via the operator tooltips inside the Logic Programmer or in the list of operators in the Logic Programming section of this book.

Since invoking operators via idContext can become quite verbose, you can choose to store operators in a custom constant variable, as shown in the second example. Alternatively, you can make use of object methods, which are discussed in the next section.

function filterItem(item) {
  return idContext.ops.itemstackStackable(item) && idContext.ops.itemstackStacksize(item) >= 16;
}
const isStackable = idContext.ops.itemstackIsStackable;
const size = idContext.ops.itemstackSize;
function filterItemCompact(item) {
  return isStackable(item) && size(item) >= 16;
}