If you want to install this mod, head over to the Releases and download the latest build (NoitaDearImGui-X.Y.Z.zip NOT the source code).
You are not expected to bundle this mod with your own mod, you should instead instruct people to install this themselves alongside your mod.
Any mod below this mod in the load order can use the ImGui bindings. This mod requires 'unsafe' mode, but mods that use the ImGui bindings don't need unsafe mode themselves.
Make sure to occassionally switch the build type to 'Debug (for devs)' during development or if the game starts crashing. This often helps identify mistakes in use of the bindings.
Also check out the ImGui FAQ: https://github.com/ocornut/imgui/blob/master/docs/FAQ.md a lot of stuff there also applies to these bindings.
There's generated documentation containing all the function signatures.
You can just refer to this file manually, but it's also possible to load into VS Code or any other editor that supports the LuaLS/Lua Language Server.
VS Code is pretty easy to setup:
- Get the Lua language server extension. https://marketplace.visualstudio.com/items?itemName=sumneko.lua
- Go into the extension's settings and add the
imguidoc
directory. This is included in the mod release zip. - It should now be working. Press ctrl+space to trigger autocomplete.
The bindings are a relatively close 1:1 mapping of the normal ImGui functions except:
-
References are used in ImGui to pass data in and alter it. Lua doesn't have references so this is turned into by-value arguments and additional return values.
-
Most structures are broken up into individual elements. So instead of a
ImVec2 size
argument, these bindings will accept two argumentssize_x
,size_y
. -
ImGui's
Begin
/BeginChild
functions have an inconsistency that's explained here. This inconsistency is fixed in the bindings. -
Enums don't have the
ImGui
prefix since you already have to use them through theimgui
table.
This standard ImGui code:
ImGui::ColorEdit3("Color", (float*)&color,
ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoAlpha);
turns into this with these Noita/Lua bindings:
_, r, g, b = imgui.ColorEdit3("Colour", r, g, b,
bit.bor(imgui.ColorEditFlags.PickerHueWheel, imgui.ColorEditFlags.NoSidePreview, imgui.ColorEditFlags.NoAlpha))
There's an example mod that shows the basics: https://github.com/dextercd/Noita-Dear-ImGui/blob/main/ExampleMod/init.lua
Many thanks to 🌸Rain🌸 (vexx32) on the Noita Discord for the Noita pixel and glyph ttf files she created: Discord message (Download).
- This repo hosts a slightly altered version with '{', '}', and '~' characters added.
Thanks to Kaedenn for creating the initial documentation using this script he made.