Integrated Dynamics · Addon guide · Advanced

Integrated Scripting Guide: Writing JavaScript for Advanced Automation

As your Integrated Dynamics networks grow, chaining dozens of Variable Cards inside multiple Variable Stores becomes a nightmare to debug and maintain. This guide will teach you how to use the Integrated Scripting addon to replace massive walls of logic operators with clean, readable JavaScript functions. You will learn how to set up a Scripting Drive, write custom scripts in the Scripting Terminal, and bind them to Variable Cards for high-level automation.

What you need

  • Integrated Dynamics and the Integrated Scripting addon installed (along with Cyclops Core and Common Capabilities)
  • An active Logic Cable network
  • Scripting Drive
  • Scripting Disk
  • Scripting Terminal
  • Variable Store
  • Several blank Variable Cards
  • A Reader of your choice (e.g., Inventory Reader or Block Reader) and a Display Panel for testing
  • Labeller (highly recommended for naming cards)

Step by step

  1. 1Set Up the Scripting Hardware

    Attach a Scripting Terminal to a piece of Logic Cable on your network, and place a Scripting Drive adjacent to the cable so it connects. Craft a Scripting Disk and insert it into the slot inside the Scripting Drive. Just like a Variable Store holds cards, the Scripting Drive makes the files on your disk accessible to the entire network.

    Tip: If your modpack has network energy consumption enabled in the configs, ensure a filled Energy Battery is connected to the network.

  2. 2Create a Script File in the Terminal

    Right-click the Scripting Terminal to open the code editor interface. On the file panel, select your inserted Scripting Disk and click the button to create a new script file, naming it something descriptive like 'automation.js'. This virtual file is stored directly on the disk item.

    Tip: You can organize different factory subsystems into separate '.js' files on the same disk.

  3. 3Write a Pure JavaScript Function

    In the central code editor, write a standard JavaScript function that takes inputs and returns a result. For example, write: 'function checkStock(count, limit) { return count < limit; }'. Keep the function pure—meaning it simply calculates an output from the given parameters without relying on external browser or Node.js features.

    Tip: The editor highlights syntax errors immediately; check the bottom bar of the terminal GUI if a red marker appears.

  4. 4Bind the Function to a Variable Card

    While your script is open in the Scripting Terminal, place a blank Variable Card into the binding slot at the bottom-right corner of the GUI. Type or select the exact name of your function ('checkStock') to bind it, then remove the newly programmed Variable Card. This card now represents an Operator data type within Integrated Dynamics.

    Tip: Immediately use a Labeller to name this card 'JS: checkStock' so you do not confuse it with normal data cards.

  5. 5Capture World Data with Readers

    Attach a Reader (such as an Inventory Reader pointing at a chest) to your network. Insert a blank Variable Card into a numerical aspect, such as the inventory count or filled slots, to create your input variable. Place both this Reader Variable Card and your JS Operator Variable Card into a connected Variable Store so the network can reference them.

  6. 6Apply the Script Operator in the Logic Programmer

    Open a Logic Programmer (either portable or block form) and search for the 'Apply' operator (or 'Apply 2' if your function takes two arguments). Place your JS Operator Variable Card into the first slot, and insert your Reader Variable Card (and a constant Integer card for the limit) into the argument slots. Place a fresh Variable Card in the output slot to encode the final evaluated expression.

    Tip: Consult the in-game guide book 'On the Dynamics of Integration' under the Functional Programming and Scripting chapters to see advanced list operations like map and filter.

  7. 7Deploy and Test on a Display Panel

    Move all prerequisite cards into your Variable Store, keeping only the final 'Apply' output Variable Card in your hand. Insert this final card into a Display Panel or a Redstone Writer on your network. The panel will now execute your JavaScript function in real time and display 'true' or 'false' as you add or remove items from the target inventory.

    Tip: If the Display Panel shows an error icon, hover over it inside the panel's GUI to read the exact evaluation or type-mismatch message.

How it works

Integrated Dynamics uses a lazy-evaluation functional logic system. Normally, if you want to check three conditions and perform math on them, you have to create a physical Variable Card for every single step (+, -, &&, <) and store all of them inside a Variable Store. The network evaluates the final card by tracing back through the dependency tree of cards every tick.

Integrated Scripting bypasses this physical card clutter by compiling a JavaScript function into a single Integrated Dynamics 'Operator' card. When you use the 'Apply' operator in the Logic Programmer, the mod automatically converts its internal variable types (like Integers, Booleans, Strings, Lists, and even complex Item/NBT objects) into JavaScript equivalents, passes them into your script engine, and translates the return value back into an Integrated Dynamics variable type.

Because the actual code lives on the Scripting Disk inside the Scripting Drive, the Variable Card itself only holds a pointer to the Disk ID, the file path, and the function name. This means you can open the Scripting Terminal and edit the math or logic inside 'checkStock' on the fly, and every Writer or Display Panel using that function will update its behavior instantly without you ever having to re-craft or replace the Variable Cards.

Common mistakes

  • Removing the Scripting Disk from the Scripting Drive: Because the Variable Card only points to the script file on the disk, taking the disk out will immediately break all downstream variables with a missing-script error.
  • Putting the JS Function Card directly into a Display Panel or Writer: A bound function card is an 'Operator' type, not a final value. If you put it directly into a Redstone Writer expecting a Boolean, it will fail; you must first pass inputs into it using the 'Apply' operator in the Logic Programmer.
  • Type mismatches between JavaScript and Integrated Dynamics: Returning 'undefined', 'null', or mixed types (like returning a number in an 'if' branch and a boolean in an 'else' branch) will cause evaluation errors on the network. Always ensure your function returns a consistent data type.
  • Forgetting to put input Variable Cards into the Variable Store: Even though your logic is inside a script, the Reader cards feeding the 'Apply' operator still must reside in a connected Variable Store.

FAQ

Can I inspect properties of Items, Fluids, or NBT inside my JavaScript code?

Yes. When you pass an Item, Fluid, or NBT Variable Card into a JavaScript function, Integrated Scripting exposes helper methods and properties on that object. Check the 'On the Dynamics of Integration' guide book in-game for the exact object methods available in your mod version.

Do I need to re-bind the Variable Card every time I edit my code?

No. As long as the function name and the number/type of parameters remain the same, you can save changes in the Scripting Terminal and the network will immediately use the updated code.

Will running JavaScript every tick lag my server?

Simple math, boolean logic, and small list filtering have negligible impact and often perform similarly to deep chains of Variable Cards. Avoid huge 'while' loops or heavy string manipulation, and remind server admins they can run '/integrateddynamics networkdiagnostics' to profile tick time per network part.

How do I pass three or more arguments into my JavaScript function?

In the Logic Programmer, use the higher-order 'Apply' operators (such as Apply 2, Apply 3), apply arguments sequentially via currying, or pack multiple values of the same type into a List Variable Card and take a single array parameter in your JS function.

By combining a Scripting Drive, a Scripting Terminal, and the Logic Programmer's Apply operator, you can condense sprawling Variable Store logic into clean, hot-swappable JavaScript functions.

More Integrated Dynamics guides

Integrated Dynamics · Addon guideIntegrated Tunnels Guide: How to Transfer Items, Fluids & Energy at Max SpeedIntegrated Tunnels expands your Integrated Dynamics networks by letting you move items, fluids, and energy across your base with zero travel delay. By mastering Interfaces, Importers, and Exporters alongside Variable Cards, you can build instant, infinitely scalable transfer systems that easily outperform standard pipes. This guide will walk you through setting up basic transfers, separating network traffic with channels, and configuring max-speed throughput.Beginner7 steps
Integrated Dynamics · Setup guideHow to Build a Storage Network with Integrated Terminals & TunnelsBuild a centralized, searchable storage and crafting system early in your survival world without needing expensive digital drives or massive power grids. By combining Integrated Dynamics with the Integrated Tunnels and Integrated Terminals addons, you can link all your existing chests, barrels, and storage drawers into one seamless interface.Beginner7 steps
Integrated Dynamics · Addon guideIntegrated Crafting Guide: How to Set Up Auto-Crafting & Machine ProcessingMastering auto-crafting with the Integrated Dynamics mod family allows you to automate both standard 3x3 crafting recipes and complex multi-step machine processing on demand. By leveraging the Integrated Crafting, Integrated Tunnels, and Integrated Terminals addons, you can build a surprisingly cheap and scalable request-based automation network early in your progression. This guide walks you through encoding Recipe Variable Cards, configuring Crafting Interfaces on tables and furnaces, and managing jobs through terminals.Intermediate7 steps
Integrated Dynamics · PowerHow to Build an Automated Menril Power Plant (Generator & Battery Guide)In this guide, you will learn how to build a self-regulating Menril power plant using Integrated Dynamics and Integrated Tunnels. By reading the fill level of your Energy Batteries, your network will automatically feed wood from a tree farm into your Generators only when power is needed, preventing fuel waste.Intermediate8 steps
Integrated Dynamics · AutomationHow to Automate Ore Processing & Mekanism Machines (Integrated Mekanism)Mekanism ore processing lines frequently jam when multi-item batches or uneven chemical slurry production flood a single machine buffer. In this guide, you will use Integrated Dynamics, Integrated Tunnels, and Integrated Mekanism to build a smart ore multiplication setup that dynamically reads chemical levels, transfers gasses and slurries over a single cable network, and balances raw ore inputs automatically.Intermediate7 steps
Integrated Dynamics · Addon guideHow to Filter NBT Data & Enchantments with Integrated NBTMob farms quickly clog your storage with damaged, randomly enchanted armor and tools that standard item filters cannot easily separate. In this advanced guide, you will learn how to use the Integrated NBT addon alongside Integrated Dynamics and Integrated Tunnels to extract deeply nested NBT tags, filter specific enchantments, and build a smart, lag-free mob drop sorting system.Advanced6 steps