# imnodes-luau Node editor (imnodes) for imgui-luau (Roblox / LÖVE). Luau port of [ImNodes](https://github.com/Nelarius/imnodes) for [imgui-luau](https://git.bug.tools/bug/imgui-luau) ([GitHub](https://github.com/4DBug/imgui-luau)). Mirrors: [git.bug.tools](https://git.bug.tools/bug/imnodes-luau) / [GitHub](https://github.com/4DBug/imnodes-luau). **Status:** near-complete port of upstream imnodes (editor, nodes, pins, links, selection, minimap, style stacks, save/load to string). Not ported: `*IniFile` save/load (no filesystem on Roblox) and the `color_node_editor` example. ## Usage ```lua local G = require(ReplicatedStorage.ImGui) local ImNodes = require(ReplicatedStorage.ImNodes)(G) local ImGui = G.ImGui ImGui.CreateContext() ImNodes.CreateContext() G.ImGui_ImplRoblox.Init() local Links = {} RunService.RenderStepped:Connect(function() G.ImGui_ImplRoblox.NewFrame() ImGui.NewFrame() ImGui.Begin("node editor") ImNodes.BeginNodeEditor() ImNodes.BeginNode(1) ImNodes.BeginNodeTitleBar() ImGui.Text("node") ImNodes.EndNodeTitleBar() ImNodes.BeginOutputAttribute(2) ImGui.Text("out") ImNodes.EndOutputAttribute() ImNodes.EndNode() for Id, L in Links do ImNodes.Link(Id, L[1], L[2]) end ImNodes.EndNodeEditor() local Created, StartAttr, EndAttr = ImNodes.IsLinkCreated() if Created then table.insert(Links, { StartAttr, EndAttr }) end ImGui.End() ImGui.Render() G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData()) end) ``` Full example: `examples/roblox/main.client.luau` — a "Logic Simulator" window (`LogicUI.lua`) over the `LogicSim.lua` model. Put `ImGui`, `ImNodes`, `LogicSim`, `LogicUI` in ReplicatedStorage. - File menu: New, Save (graph + editor layout to an in-memory string), Load, Clear (drop saved text), Show Save Text (copyable). - Examples menu: Half Adder, Full Adder (default), 4-bit Ripple Adder, SR Latch, Blinker. - Right-click canvas: Add Node (Inputs/Gates/Outputs/Memory); right-click node: Duplicate/Delete; right-click link: Delete. - Delete/Backspace removes selected nodes and links. Lit pins/links are green. ## API differences - Pointer out-params become return values: `IsLinkCreated() -> created, start_attr, end_attr, from_snap`, `IsLinkDestroyed() -> destroyed, link_id`, `IsNodeHovered() -> hovered, node_id`, `IsLinkDropped(...) -> dropped, attr_id`, etc. Getters like `GetNodeGridSpacePos` / `EditorContextGetPanning` return copies. - The C++ `IsLinkCreated(int*, int*, int*, int*, bool*)` overload is `IsLinkCreatedWithNodes() -> created, start_node, start_attr, end_node, end_attr, from_snap`. - `ImNodesIO.*.Modifier` is `nil` or a function returning bool instead of a `const bool*`: `ImNodes.GetIO().LinkDetachWithModifierClick.Modifier = function() return ImGui.GetIO().KeyCtrl end`. - `SaveCurrentEditorStateToIniString()` / `SaveEditorStateToIniString(editor)` return a string (no `data_size`); `LoadCurrentEditorStateFromIniString(s)` / `LoadEditorStateFromIniString(editor, s)` take one. Persist it via DataStore etc. - `EditorContextFree` is a no-op (GC). ## Development ```sh git clone --recursive https://git.bug.tools/bug/imnodes-luau.git bash tools/test.sh # tests/t_*.luau in the core's Roblox mock ``` Upstream source (pinned) is in `tools/upstream/`; port-specific comments are tagged `[Port]`. ## License MIT, see LICENSE (upstream copyright kept).