window:Button
win:Button(text[, onClick]) Returns: button control table.
| Parameter | Meaning |
|---|---|
| text | Button caption. |
| onClick optional | Function called when clicked. |
win:Button('Heal', function()
Spells.Cast('Greater Heal')
end)
Scripts can build real windows — status displays, loot toggles, one-click
panels. Layout is automatic (top to bottom, or side by side with
Row), and controls can bind to functions so they
update themselves while the script runs.
UI.Window(title) creates a window; factory methods on the
window (Label, Button, Checkbox,
TextBox, Slider, ProgressBar,
Separator) add controls in order.OnClick, OnChange,
OnClose) and bindings (ctl:Bind(fn)) run while
your script is inside Pause(ms) — a script that never
pauses has a frozen window.win:Run() is the convenience loop for pure UI scripts: it
shows the window and pumps until it is closed.UI.DestroyAll() closes everything a script created —
windows are also cleaned up when the script stops.local win = UI.Window('Health Watch')
win:Label('Your vitals:')
local bar = win:ProgressBar(0, 100)
bar:Bind(function() return Player.Hits / Player.HitsMax * 100 end)
win:Row() -- next controls share one line
local heal = win:Button('Heal')
heal:OnClick(function()
local b = Items.FindByType(0xE21) -- bandages
if b then Player.UseObject(b.Serial) end
end)
local quit = win:Button('Close')
quit:OnClick(function() win:Close() end)
win:Run() -- show + pump until closed win:Button(text[, onClick]) Returns: button control table.
| Parameter | Meaning |
|---|---|
| text | Button caption. |
| onClick optional | Function called when clicked. |
win:Button('Heal', function()
Spells.Cast('Greater Heal')
end) win:Checkbox(text[, checked][, onChange]) The onChange callback receives the new checked state; it can be passed as the second or third argument. Returns: checkbox control table.
| Parameter | Meaning |
|---|---|
| text | Checkbox label. |
| checked optional | Initial state (default false). |
| onChange optional | Function called with the new value on toggle. |
local auto = win:Checkbox('Auto-heal', true, function(v)
print('auto-heal: ' .. tostring(v))
end) win:Close() A win:Run() loop waiting on this window ends when it closes. Returns: true.
win:Button('Done', function() win:Close() end) win:Hide() Returns: the window table (chainable).
win:Hide() win:IsOpen() Returns: boolean.
while win:IsOpen() do
Pause(100)
end win:Label(textOrFn[, intervalMs]) Pass a string for a static label, or a function returning a string for a live-bound label that refreshes automatically (default every 200 ms; pass intervalMs to change). Returns: label control table.
| Parameter | Meaning |
|---|---|
| textOrFn | Label text, or a function returning the text. |
| intervalMs optional | Refresh interval for bound labels (default 200). |
win:Label(function() return 'HP: ' .. Player.Hits .. '/' .. Player.HitsMax end) win:OnClose(fn) Returns: the window table (chainable).
| Parameter | Meaning |
|---|---|
| fn | Function called when the window closes. |
win:OnClose(function()
Messages.Info('Window closed - stopping.')
StopScript()
end) win:ProgressBar([valueOrFn][, intervalMs]) Pass a number for a static value, or a function returning 0..1 for a live-bound bar (default refresh every 200 ms). Returns: progress bar control table.
| Parameter | Meaning |
|---|---|
| valueOrFn optional | Value 0..1, or a function returning it. |
| intervalMs optional | Refresh interval for bound bars (default 200). |
win:ProgressBar(function() return Player.Hits / Player.HitsMax end) win:Row() The returned row table offers the same element factories as the window (Label, Button, Checkbox, TextBox, Slider, ProgressBar, Separator). Returns: row table.
local row = win:Row()
row:Button('Start', startFn)
row:Button('Stop', stopFn) win:Run([intervalMs]) The convenience main loop for UI scripts: processes button clicks, change events and bindings roughly every 50 ms (or the given interval) until the window closes. Returns: true when the window has closed.
| Parameter | Meaning |
|---|---|
| intervalMs optional | Pump interval in milliseconds (default 50, minimum 20). |
local win = UI.Window('My tool')
win:Button('Close', function() win:Close() end)
win:Run() win:Separator() Returns: true.
win:Separator() win:SetPosition(x, y) Returns: the window table (chainable).
| Parameter | Meaning |
|---|---|
| x | Screen X position. |
| y | Screen Y position. |
win:SetPosition(100, 100) win:SetSize(width, height) Returns: the window table (chainable).
| Parameter | Meaning |
|---|---|
| width | New width. |
| height | New height. |
win:SetSize(250, 300) win:SetTitle(title) Returns: the window table (chainable).
| Parameter | Meaning |
|---|---|
| title | New title text. |
win:SetTitle('Helper - running') win:Show() Returns: the window table (chainable).
win:Show() win:Slider(min, max[, initial][, onChange]) Returns: slider control table.
| Parameter | Meaning |
|---|---|
| min | Minimum value. |
| max | Maximum value. |
| initial optional | Initial value. |
| onChange optional | Function called with the new value on change. |
local threshold = win:Slider(0, 100, 60) win:TextBox([text][, onChange]) The onChange callback receives the new text; it can be passed as the first or second argument. Returns: textbox control table.
| Parameter | Meaning |
|---|---|
| text optional | Initial text. |
| onChange optional | Function called with the new text on change. |
local nameBox = win:TextBox('')
nameBox:SetPlaceholder('Pet name...') ctl:Bind(fn[, intervalMs]) The function runs periodically (default every 200 ms, minimum 50) and its return value updates the control: a string for labels, a number 0..1 for progress bars. Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| fn | Function returning the new value. |
| intervalMs optional | Refresh interval in milliseconds (default 200). |
hpBar:Bind(function() return Player.Hits / Player.HitsMax end, 100) ctl:GetText() Returns: string.
local name = nameBox:GetText() ctl:GetValue() Returns: number.
local pct = threshold:GetValue() ctl:IsChecked() Returns: boolean.
if auto:IsChecked() then
Spells.Cast('Greater Heal')
end ctl:OnChange(fn) The callback receives the new value: boolean for checkboxes, string for text boxes, number for sliders. Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| fn | Function called with the new value. |
threshold:OnChange(function(v)
print('threshold: ' .. v)
end) ctl:OnClick(fn) While a control's callback is still running, further events for the same control are dropped (double-click debounce). During a long callback that calls Pause(), other short callbacks - like a stop button - are still delivered. Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| fn | Function called when the button is clicked. |
myButton:OnClick(function()
Messages.Info('Clicked!')
end) ctl:SetChecked(checked) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| checked | true or false. |
auto:SetChecked(false) ctl:SetColor(color) Accepts a hex string ('#FF0000' or 'FF0000') or three numbers r, g, b in the 0-255 range: ctl:SetColor(255, 0, 0). Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| color | '#RRGGBB' string, or r, g, b as three numbers. |
status:SetColor('#FF4040') ctl:SetEnabled(enabled) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| enabled | true to enable, false to gray out. |
startButton:SetEnabled(false) ctl:SetPassword([enabled]) With no argument (or true) the text is masked; pass false to show it again. Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| enabled optional | true to mask input (default true). |
secretBox:SetPassword() ctl:SetPlaceholder(text) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| text | Placeholder text shown when the box is empty. |
nameBox:SetPlaceholder('Enter pet name...') ctl:SetText(text) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| text | New text. |
status:SetText('Working...') ctl:SetValue(value) Slider values are clamped to the slider's min/max range; progress bar values are 0..1. Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| value | New value. |
hpBar:SetValue(0.5) ctl:SetVisible(visible) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| visible | true to show, false to hide. |
status:SetVisible(false) ctl:SetWidth(width) Returns: the control table (chainable).
| Parameter | Meaning |
|---|---|
| width | Width in pixels. |
nameBox:SetWidth(180)
Nothing matches that. Try find, gump or wait.