ImGui
BeamNG ImGui Cheat Sheet
local im = ui_imgui
local im = ui_imgui
local ffi = require("ffi")Windows
im.Begin("Title") -- Basic window
im.Begin("Title", boolPtr) -- With close button (X)
im.Begin("Title", nil, flags) -- With flags
im.End() -- ALWAYS call (even if Begin=false)
im.BeginChild1("id", size, border) -- Scrollable sub-region
im.EndChild()Text
im.Text("Hello %s", name) -- Formatted text
im.TextColored(im.ImVec4(r,g,b,a), "text") -- Colored
im.TextWrapped("Long text...") -- Word-wrapped
im.TextDisabled("Greyed out") -- Dimmed
im.BulletText("List item") -- Bulleted
im.SeparatorText("Section") -- Text with separator line
im.LabelText("Label", "Value") -- Label: Value alignedButtons
im.Button("Click", im.ImVec2(w, h)) -- Returns true on click
im.SmallButton("small") -- Compact button
im.ArrowButton("id", im.Dir_Right) -- Arrow button
im.InvisibleButton("id", im.ImVec2(w, h)) -- Clickable area, no visualInputs
-- Numeric
im.InputInt("Label", intPtr, step, fastStep)
im.InputFloat("Label", floatPtr, step, fastStep, "%.2f")
im.InputDouble("Label", doublePtr, step, fastStep, "%.5f")
-- Sliders
im.SliderInt("Label", intPtr, min, max)
im.SliderFloat("Label", floatPtr, min, max, "%.1f")
im.SliderAngle("Angle", floatPtr, min, max)
im.VSliderFloat("Label", im.ImVec2(w,h), floatPtr, min, max)
-- Drag (click+drag to change)
im.DragFloat("Label", floatPtr, speed, min, max)
im.DragInt("Label", intPtr, speed, min, max)
-- Text
im.InputText("Label", arrayChar, bufSize)
im.InputText("Label", buf, 256, im.InputTextFlags_EnterReturnsTrue)
im.InputTextMultiline("Label", buf, bufSize, im.ImVec2(w, h))
im.InputTextWithHint("Label", "placeholder...", buf, bufSize)
-- Bool
im.Checkbox("Label", boolPtr)
-- Radio
im.RadioButton2("A", intPtr, im.Int(0))
im.RadioButton2("B", intPtr, im.Int(1))Selectors
-- Combo (dropdown)
if im.BeginCombo("Label", previewText) then
for i, item in ipairs(items) do
if im.Selectable1(item, i == selected) then selected = i end
end
im.EndCombo()
end
-- Selectable (list item)
im.Selectable1("Item", isSelected)
-- Color
im.ColorEdit3("Color", floatArray3)
im.ColorEdit4("Color", floatArray4)
im.ColorPicker4("Picker", floatArray4)Layout
im.SameLine() -- Next widget on same line
im.Spacing() -- Small vertical space
im.Separator() -- Horizontal line
im.NewLine() -- Force new line
im.Indent() -- Increase indent
im.Unindent() -- Decrease indent
im.Dummy(im.ImVec2(w, h)) -- Invisible spacer
im.SetNextItemWidth(200) -- Width of next widget
im.PushItemWidth(200) -- Width of all widgets until Pop
im.PopItemWidth()
im.BeginGroup() -- Group widgets (for layout)
im.EndGroup()
im.GetContentRegionAvail() -- Available space (.x, .y)
im.GetCursorPos() -- Current cursor position
im.SetCursorPosX(x) -- Set horizontal positionContainers
-- Collapsible header
if im.CollapsingHeader1("Section") then ... end
-- Tree node
if im.TreeNode1("Node") then
im.Text("Child")
im.TreePop() -- REQUIRED
end
-- Tab bar
if im.BeginTabBar("tabs") then
if im.BeginTabItem("Tab 1") then ... im.EndTabItem() end
if im.BeginTabItem("Tab 2") then ... im.EndTabItem() end
im.EndTabBar()
end
-- Table
if im.BeginTable("id", numColumns, flags) then
im.TableSetupColumn("Col1")
im.TableHeadersRow()
im.TableNextRow()
im.TableSetColumnIndex(0)
im.Text("cell")
im.EndTable()
endPopups & Modals
im.OpenPopup("id") -- Open popup
if im.BeginPopup("id") then ... im.EndPopup() end
if im.BeginPopupModal("id") then ... im.EndPopup() end
im.CloseCurrentPopup()
-- Context menu (right-click)
if im.BeginPopupContextItem("id") then ... im.EndPopup() endMenus
-- In a window with WindowFlags_MenuBar
if im.BeginMenuBar() then
if im.BeginMenu("File") then
if im.MenuItem1("Save") then ... end
im.EndMenu()
end
im.EndMenuBar()
endStyling
-- Colors (push/pop)
im.PushStyleColor2(im.Col_Text, im.ImVec4(r,g,b,a))
-- ... widgets ...
im.PopStyleColor(count)
-- Variables (push/pop)
im.PushStyleVar1(im.StyleVar_WindowBorderSize, 0)
im.PushStyleVar2(im.StyleVar_WindowPadding, im.ImVec2(10, 10))
-- ... widgets ...
im.PopStyleVar(count)
-- Disable widgets
im.BeginDisabled(true)
-- ... greyed out widgets ...
im.EndDisabled()State Queries
im.IsItemHovered() -- Mouse over last widget?
im.IsItemClicked() -- Clicked last widget?
im.IsItemActive() -- Holding/interacting?
im.IsItemEdited() -- Value changed?
im.IsItemDeactivatedAfterEdit() -- Released after editing?
im.IsItemVisible() -- In visible area?
im.IsWindowFocused() -- Window has focus?
im.IsWindowHovered() -- Mouse over window?
im.IsAnyItemActive() -- Any widget active?
im.IsMouseClicked(0) -- Left mouse clicked? (0=left,1=right)
im.IsMouseDoubleClicked(0)
im.GetMousePos() -- Mouse position (.x, .y)IDs
im.PushID1("string_id") -- String-based ID scope
im.PushID4(intId) -- Int-based ID scope
im.PopID()
-- Or use ## in labels:
im.Button("Click##unique1")
im.Button("Click##unique2")Plots
-- MUST use TableToArrayFloat + GetLengthArrayFloat (not raw tables or ffi cdata)
local data = im.TableToArrayFloat({10, 20, 30, 40, 50})
im.PlotLines1("##plot", data, im.GetLengthArrayFloat(data), 0, "overlay", 0, 100, im.ImVec2(200, 80))
im.PlotHistogram1("##hist", data, im.GetLengthArrayFloat(data), 0, "overlay", 0, 100, im.ImVec2(200, 80))Draw Lists
local dl = im.GetWindowDrawList()
local c = im.GetColorU322(im.ImVec4(r,g,b,a))
im.ImDrawList_AddLine(dl, p1, p2, c, thickness)
im.ImDrawList_AddRect(dl, p1, p2, c, rounding, flags, thickness)
im.ImDrawList_AddRectFilled(dl, p1, p2, c, rounding, flags)
im.ImDrawList_AddCircle(dl, center, radius, c, segments, thickness)
im.ImDrawList_AddCircleFilled(dl, center, radius, c, segments)
im.ImDrawList_AddTriangleFilled(dl, p1, p2, p3, c)
im.ImDrawList_AddText1(dl, pos, c, text)Common Flag Combinations
-- Fixed utility window
im.WindowFlags_AlwaysAutoResize + im.WindowFlags_NoCollapse + im.WindowFlags_NoResize
-- Overlay (no interaction)
im.WindowFlags_NoTitleBar + im.WindowFlags_NoResize + im.WindowFlags_NoMove + im.WindowFlags_NoInputs + im.WindowFlags_NoBackground
-- Full editor window
im.WindowFlags_MenuBar
-- Borderless child
im.BeginChild1("id", size, false, im.WindowFlags_NoScrollbar)BeamNG ImGui API Reference
All functions via `local im = ui_imgui`. Types: `BoolPtr`, `IntPtr`, `FloatPtr` are `{[0]=value}` tables. `ArrayChar` is a string buffer. `ImVec2(x,y)` and `ImVec4(x,y,z,w)` are engine structs.
BeamNG ImGui Data Types
ImGui uses C-style pointers for mutable values. BeamNG wraps these as Lua tables with a `[0]` index.