Nexo Maker Docs
  • Welcome
  • Getting Started
    • Basic Concepts
      • Starting a Expansion
      • Compiling your Expansion
  • Visual API
    • Modularjs
      • Modularjs Basics
      • Styling
      • useState()
      • useEffect()
      • useGlobalState()
      • useProjectState()
    • [Deprecated] Components
      • Custom HTML documents
    • Themes
      • Replace Assets
      • Assets List
  • Functional API
    • Post Functions
      • Post Sidebar Button
      • Post Editor Module
    • Get Functions
      • Load Assets
      • Load File
      • Get Project
  • API Changelogs
    • Changelog 0.6.1
Powered by GitBook
On this page
  • 📘 Syntax
  • 🧩 Parameters
  • 📤 How It Works
  1. Functional API
  2. Post Functions

Post Editor Module

The postModule() function registers a new module in your Nexo Maker expansion. It ties together metadata, shared variables, UI components, and YAML paths for activation.

This function is synchronous and does not return any values.

Modules are global by nature, which means any registered module can be seen by the renderer as long as module conditions are met.


📘 Syntax

nm.postModule({
  title: string,
  id: string,
  type: string,
  condition?: string[],
  description?: string,
  variables?: string[],
  components?: Array<{
    title: string,
    element: string,
    placeholder?: string,
    value: string,
    module: string
  }>
});

🧩 Parameters

  • title (string) Human-readable name shown in the editor.

  • id (string) Unique identifier for internal reference.

  • type (string) Category of the module (e.g. "modules").

  • condition (string[]) [optional] Array of condition keys; the module only shows if all conditions are truthy. If no conditions are given, any Nexo Maker element type can use this module.

  • description (string) [optional] Brief description shown in tooltips or lists.

  • variables (string[]) [optional] Names of shared variables to register in module.variables.

  • components (array) [optional] UI components to render, each binding to a shared variable and a YAML path.

✔️ condition

Declares which element types are considered valid to display the module.

condition: ["isItem"]

🔁 variables

Declares which shared variables this module will read/write.

variables: ["itemvalue"]
  • Registers test and materials in the global module.variables store.

  • Other modules referencing these names will see updates.

🧩 components

Defines one or more interactive UI elements tied to shared variables and YAML.

components: [{
  title:       "Test",
  element:     "input/number",
  placeholder: "5",
  value:       "itemvalue",
  module:      "economy"
}]

Each component object supports:

  • title (string) Label shown next to the input.

  • element (string) Type of UI control (e.g. "input/text", "input/number", "input/checkbox", etc.).

  • placeholder (string) [optional] Default placeholder text for input fields.

  • value (string) Key in module.variables to bind the component’s value.

  • module (string) Slash-delimited YAML path where this component’s value is stored and used to detect module activation.


📤 How It Works

  1. Add variables & metadata

    module.type = "modules";
    module.condition = ["isItem"];
    module.variables = ["value"];
    module.components = [{
        title: "Value",
        element: "input/number",
        placeholder: "12",
        value: "value",
        module: "economy/value"
    }];
    module.id = "economyessentials";
    module.title = "TEST";
    module.description = "Test description";
  2. Register module into expansion

    nm.postModule(module);
  3. Render component

  • The "Test" input displays the current materials value (or the placeholder 5 if unset).

  • Changes are instantly reflected in element's yaml file.

  1. Persist to YAML

  • For example, if you have a yaml file located atProjects/my-project/Nexo/valuables/items.yaml:

    ruby:
      Pack:
        model: my-project:valuables/ruby
        texture: my-project:valuables/ruby.png
      itemname: Ruby
      material: PAPER
  • Updated input data would get written into items.yam file, which would look something like this after editing element value input:

    ruby:
      Pack:
        model: my-project:valuables/ruby
        texture: my-project:valuables/ruby.png
      itemname: Ruby
      material: PAPER
      economy: 
        value: 12

✅ Full Example

nm.postModule({
  title:       "Economy Essentials",
  id:          "economyessentials",
  type:        "modules",
  condition:   ["isItem"],
  description: "Test description",
  variables:   ["value"],
  components: [{
    title:       "Test",
    element:     "input/number",
    placeholder: "12",
    value:       "value",
    module:      "economy"
  }]
});

Condition: only shows if editing ITEM element type.

Variable binding: shares materials with other modules.

YAML path: writes under the material: key.

⚠️ Notes

  • Choose unique, descriptive keys to avoid naming collisions.

  • Writing to a variable in one module immediately affects any other module reading it.

PreviousPost Sidebar ButtonNextGet Functions

Last updated 18 days ago

For more information about valid element types, check out documentation.

Nexo Maker Elements