53d4cfba7584b338216c2206e83cf3c056679c63
imnodes-luau
Node editor (imnodes) for imgui-luau (Roblox / LÖVE).
Luau port of ImNodes for imgui-luau (GitHub). Mirrors: git.bug.tools / GitHub.
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
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 (ports of upstream hello, multi_editor, save_load): examples/roblox/main.client.luau.
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 likeGetNodeGridSpacePos/EditorContextGetPanningreturn copies. - The C++
IsLinkCreated(int*, int*, int*, int*, bool*)overload isIsLinkCreatedWithNodes() -> created, start_node, start_attr, end_node, end_attr, from_snap. ImNodesIO.*.Modifierisnilor a function returning bool instead of aconst bool*:ImNodes.GetIO().LinkDetachWithModifierClick.Modifier = function() return ImGui.GetIO().KeyCtrl end.SaveCurrentEditorStateToIniString()/SaveEditorStateToIniString(editor)return a string (nodata_size);LoadCurrentEditorStateFromIniString(s)/LoadEditorStateFromIniString(editor, s)take one. Persist it via DataStore etc.EditorContextFreeis a no-op (GC).
Development
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).
Languages
Lua
88.5%
Luau
9.5%
Shell
2%