Mod:Component Explorer

From Noita Wiki
Jump to navigation Jump to search

Component Explorer is a mod with a bunch of useful utilities for modders.

It has the following features:

  • Entity and component viewer
  • Lua console
  • logger.txt window and overlay
  • Magic Numbers (Steam Only)
  • Debug (Steam Only)
  • Wiki Wands

Installation

Get the latest version of Component Explorer from the Steam Workshop or via the GitHub releases (ComponentExplorer-X.Y.Z.zip).

Component Explorer uses Mod:Noita Dear ImGui for its user interface, so you must install this mod as well. It's available on GitHub (NoitaDearImGui-X.Y.Z.zip). It's best to install the newest version of ImGui and occasionally check back for updates. While CE can work with older version of ImGui, many small features and ergonomic improvements only work on the later versions.

Your mods folder will look something like this after installing everything manually:

Component Explorer Manual Install.png

If you installed Component Explorer via Steam, then that won't appear in the mods folder here.

The unsafe-explorer mod is included with the GitHub Component Explorer releases. It's an optional mod that requires unsafe mode and enables some extra features like:

In game

  • The 'Unsafe mods' option must be set to 'Allowed' to enable NoitaDearImGui. This option is to the right of the mods list.
  • Make sure that NoitaDearImGui is above Component Explorer in the load order, else the mod doesn't work.
  • If you have unsafe-explorer installed, then it should also be below NoitaDearImGui to work.

ComponentExplorer load order.png

Usage

Once Component Explorer is properly installed, you should see a small menu bar in the top right of the Noita window, you can adjust the position of this menu bar in the mod settings. From the 'View' menu in the menu bar you can toggle on/off features of Component Explorer.

Entity list

The entities list window displays all entities that currently exist. By default child entities are not in the list but you can use the checkbox to include them. The search input will look for matches in the Name, Tags, and File fields.

Once you find the entity you're interested in, you can use the 'Open' button to create a new window for operating on that entity.

ComponentExplorer Entities list.png

Entity picker

Another way to open an entity window is by using the 'Entity Picker' functionality, this allows you to select an entity that's on your screen.

Activate the picker by using the 'Entity Picker' option in the view menu or by using the keyboard shortcut ctrl+shift+e. Once activated, you should see a window following the cursor. When the cursor is near one or more entities, they should appear in the window as a numbered list. Hitting the digit corresponding to an entity should open up a new entity window. You can use ctrl+shift+e or escape to cancel the action.

Entity window

The entity window shows all kind of properties of the entity and allows you to change a lot of them.

The Attributes section shows some basic info on the entity, such as it's position, rotation, scale, it's name and it's filename. There's a button to remove the entity and a button to copy the entity XML to your clipboard.

The Tags section shows all tags the entity has. You can remove tags or add new ones, there's a button for toggling tags that are commonly used.

The Child Entities section shows a tree-view of all child entities. You can use the buttons to the right of the entities to open up a new entity window for them.

The Components section lists all component on the entity. You can enable/disable components from here or add new ones. The 'Open' button opens up a new window for operating on the component.

Component window

The component window allows you to investigate and change various properties of a component.

From the Attributes section you can copy the component's XML to the clipboard. You can also enable/disable the component or remove it completely from the entity.

The Tags section allows you to remove and add tags to the component. On the beta version you can change arbitrary tags while the main branch only allows you to toggle certain special tags via the ui.

Members, Privates, Privates, Objects, and Custom data types section correspond with the same sections listed in the tools_modding/component_documentation.txt file. You can view and change the component's field values from here. Note that not all fields are currently available.

Component/Entity windows toggle

If you've opened up a bunch of component or entity windows you can use these two menu options to get them out of the way for a bit. Once you re-enable the toggles, the windows should reappear.

Lua Console

The Lua console allows quick and easy code evaluation.

You can print values or return them. Using return will recursively print out tables in a human readable format, instead of what print gives you which is something like "table: 0x160501d8".

From the Lua console, you can use internal functions of Component Explorer. For instance, running watch_entity(1) will open up an entity window for the entity with ID 1.

Right clicking on a command you evaluated will show several options, such as copying the command/output or reevaluating the command.

ComponentExplorer Lua Console.png

Special Functions

Code you run in the console runs within Component Explorer's Lua context, which means you have access to most of CE's functionality from here. There's no documentation for most functions since they're meant for internal use only. You can look at CE's source code and try to use them, and they'll probably work like you'd expect, but there's no guarantee of that and they may change in future versions.

These functions are designed to be used from the Lua Console or user scripts:

  • user_script(script_name): Run a user script.
  • add_marker(entity_id): Add an emissive sprite and ID that follows the entity. Useful when working with invisible entities.
  • remove_marker(entity_id): Undo add_marker.
  • ModTextFileSetContent, ModTextFileGetContent, ModTextFileWhoSetContent vanilla functions smuggled past mod-init.
  • EZWand: Horscht's amazing wand manipulation library. https://github.com/TheHorscht/EZWand
  • cursor.pos(): Get current cursor position.
  • cursor.set_pos(x, y, make_visible?): Set current cursor position.
  • watch_entity(entity_id): Open entity window.
  • unwatch_entity(entity_id): Close entity window.
  • watch_component(entity_id, component_id): Open component window.
  • unwatch_component(component_id): Close component window.
  • watch_global(name, datatype): Add entry to the globals window.
  • unwatch_global(name): Remove entry from globals window.
  • watch_file(file_path): Open file in file viewer window.
  • unwatch_file(file_path): Close tab in file viewer window.

User Scripts

This feature requires the 'unsafe-explorer' mod.

For code you want to rerun often, you can put them in a special folder so they show up in the "User Scripts" window. Hitting the button that corresponds to the script will run the script inside the console. The scripts must be placed in the user-scripts folder inside your Noita installation (the same place that contains noita.exe).

Logger window/overlay

This feature requires the 'unsafe-explorer' mod.

The logger window/overlay displays the contents of the logger.txt file. Be sure to install the Enable Logger mod to get the most use out of this.

The overlay can not be scrolled back to see earlier entries, this is possible with the logger window if you turn off auto scroll.

Magic Numbers (Steam Only)

This feature requires the 'unsafe-explorer' mod.

View and edit magic number values. Only available on the latest (April 23 2021) Steam version of noita.exe.

It's normally not possible to change magic numbers from a mod because there's no option for it in the modding API. This was implemented by finding the addresses where the magic numbers are located and then reading/writing them using the unrestricted modding API. Since the game doesn't expect most of these numbers to change during a run, changing values might not have any effect or may make the game unstable. A lot of stuff does work as expected.

Debug (Steam Only)

This feature requires the 'unsafe-explorer' mod.

Enable debug features inside the Steam version of noita.exe. These features are normally only available in noita_dev.exe.

Many debug settings work but some require other debug settings to be enabled. The disclaimer for the magic numbers also count for this window.. it's normally not possible to enable these feature from a mod so it may cause instability. It's still very useful :^)

Wiki Wands

Turns the currently held wand into Template:Wand or Template:Wand Card format. You can copy the text and paste it right into this wiki!

You can also copy wands from the wiki and import them into your game!

You can add this line to your personal wiki common.js file to add a "Copy Template" button to all wands on the wiki.

importScript('User:DexterCD/wandCopy.js');

Settings

Component Explorer has a bunch of settings so that you can tune it to your personal tastes. If you think some behaviour of Component Explorer should be customisable, give me a ping and I'll think about it!

Main Window

Choose where the main/control window should go. This is the menu bar through which you open/close individual features. You can put the menu on any side of the screen and choose how far left/right or up/down it should go on the side that you selected.

The main window settings take effect as soon as you unpause the game.

Default Windows

Choose what windows should be open at the start of a run. These settings take effect as soon as you start a new run or restart the game.

XML defaults

Choose how the entities/components should be serialized to XML. These settings take effect as soon as you start a new run or restart the game.

Pause settings

Whether the Component Explorer windows should be visible while the game is paused. These settings take effect as soon as you start a new run or restart the game.

Keeping CE running while paused can be great when investigating short-lived entities like projectiles. While paused, you can still open the entity and browse through their components.

Development

Component Explorer is still in active development. Its source code is hosted on GitHub: https://github.com/dextercd/Noita-Component-Explorer. You're more than welcome to open merge requests or raise issues there. You can also post question or issues in the Discord release post.

This project uses Python/Jinja2 to generate the UI and XML serialisation code for all 160 different components. CMake is a build system that's used to orchestrate this and create the final mod zip file. As long as you're not making changes to the generated code, you shouldn't have to worry too much about this when developing fixes or new features. Give me a ping in Discord (dextercd) if you wish to contribute and need any help.