### Create and Build a GUI Window with GUIBuilder (Lua)
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder
Demonstrates the minimal usage of GUIBuilder to create a new instance, define a window with specific properties, and then build/display that window. It requires the Tinkr library and specifically the GUIBuilder utility.
```Lua
local Tinkr = ...
local GUIBuilder = Tinkr.Util.GUIBuilder
-- Create a new instance of GUIBuilder.
local Builder = GUIBuilder:New {
-- This is the name of your configs .json file, all settings will be stored in
-- this file. GUIBuilder will manage this file, just make sure the name is
-- unique enough that no other GUIs will share the same name.
config = "example_empty" -- would be `configs/example_empty.json`
}
-- Create a Window element, with no content.
local Window = Builder:Window {
key = "example_window",
title = "Empty Window",
width = 250,
height = 350,
content = { }
}
-- Build the GUI element, this shows the window.
Builder:Build(Window)
```
--------------------------------
### Get Power Level - Lua Examples
Source: https://docs.tinkr.site/Routine/Conditions/power
Demonstrates how to use the 'power' function in Lua to retrieve various power types for the player or a target unit. It shows examples for fetching Lunar Power, default Mana, and target Mana.
```lua
local playerAstral = power(PowerType.LunarPower)
local playerMana = power()
local targetMana = power(PowerType.Mana, 'target')
```
--------------------------------
### Lua: Dropdown Menu Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Showcases the creation of dropdown menus using Tinkr's GUI builder. Dropdowns allow users to select an option from a list. This example demonstrates standard dropdowns and multi-select dropdowns, defining key-value pairs for the options.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local DropdownGroup = Builder:Group {
title = "Standard Dropdowns",
content = {
Builder:Rows {
Builder:Columns {
Builder:Dropdown {
key = 'dropdown_a',
label = "Example Dropdown A",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D",
option_e = "Option E",
}
},
Builder:Dropdown {
key = 'dropdown_b',
label = "Example Dropdown B",
multi = true,
```
--------------------------------
### Create Dropdowns
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Configures standard dropdown menus, supporting both single selection and multi-selection. Each dropdown is defined with a key, label, and a map of values.
```lua
local DropdownGroup = Builder:Group {
title = "Standard Dropdowns",
content = {
Builder:Rows {
Builder:Columns {
Builder:Dropdown {
key = 'dropdown_a',
label = "Example Dropdown A",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D",
option_e = "Option E",
}
},
Builder:Dropdown {
key = 'dropdown_b',
label = "Example Dropdown B",
multi = true,
description = "This dropdown allows selecting multiple values.",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D",
option_e = "Option E",
}
}
}
}
}
}
```
--------------------------------
### Lua: Basic Checkbox Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Demonstrates the creation of simple checkboxes using Tinkr's GUIBuilder. Checkboxes allow for binary (yes/no) state selection, useful for enabling or disabling features. This example includes checkboxes with and without descriptions.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local SimpleCheckboxes = Builder:Group {
title = "Simple Checkboxes",
content = {
Builder:Text "Checkboxes allow you to have 2 states (yes and no) which can be used for enabling or disabling functionality.",
Builder:Spacer { },
Builder:Checkbox {
key = "checkbox_a",
label = "Checkbox A",
description = "Description for Checkbox A."
},
Builder:Checkbox {
key = "checkbox_b",
label = "Checkbox B",
description = "Description for Checkbox B."
},
Builder:Checkbox {
key = "checkbox_c",
label = "Checkbox C"
}
}
}
```
--------------------------------
### Build GUI Window with Tabs and Elements
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Constructs a GUI window titled 'GUI Example' containing a tab group. The tab group includes various input elements like EditBox, Dropdown, Slider, and ColorPicker. This code utilizes a 'Builder' pattern for UI construction.
```lua
local TabGroup = Builder:TabGroup {
key = "tab_group_a",
tabs = {
Builder:Tab {
key = "tab_a",
title = "Tab A",
content = {
Builder:EditBox {
key = "editbox_a",
label = "Example Edit Box A",
placeholder = "Enter text here"
},
Builder:Spacer { },
Builder:EditBox {
key = "editbox_b",
label = "Example Edit Box B",
placeholder = "Enter password here",
password = true
},
Builder:Spacer { },
Builder:Dropdown {
key = 'dropdown_b',
label = "Example Dropdown B",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D"
}
},
Builder:Spacer { },
Builder:EditBox {
key = "editbox_c",
label = "Edit Box C",
placeholder = "Placeholder Value",
description = "This input requires you to click " .. OKAY,
button = true
},
Builder:Spacer { },
Builder:Dropdown {
key = 'dropdown_a',
label = "Example Dropdown A",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D",
option_e = "Option E",
}
},
Builder:Spacer { },
Builder:Slider {
key = 'slider_a',
label = "Example Slider A",
description = "This slider ranges from 0% (0) to 100% (1).",
},
Builder:Spacer { },
Builder:ColorPicker {
key = 'color_a',
label = "Example Color Picker A",
description = "This does not include an alpha value."
},
}
}
}
}
local Window = Builder:Window {
key = "gui_example",
title = "GUI Example",
width = 350,
height = 500,
content = {
TabGroup
}
}
Builder:Build(Window)
```
--------------------------------
### Movement Utility Usage Example (Lua)
Source: https://docs.tinkr.site/Modules/Util/Movement
Demonstrates the basic usage of the Tinkr.Util.Movement functions by hooking into movements and toggling their state. This example assumes Tinkr and its Movement utility are properly initialized.
```lua
local Tinkr = ...
local Movement = Tinkr.Util.Movement
Movement:Hook()
Movement:Toggle()
```
--------------------------------
### Tinkr HTTP Module: Deprecated methods for GET and POST
Source: https://docs.tinkr.site/Modules/Util/HTTP
Provides examples of deprecated HTTP methods like HTTP:GET and HTTP:POST, intended for legacy code. It also shows the usage of the HTTP:Params helper for constructing POST request parameters. These methods are not recommended for new development.
```lua
-- An example of a HTTP GET
HTTP:GET('https://example.com', function (status, res)
if status == 200 then
print(res)
end
end)
-- An example of the HTTP Params helper
local params = HTTP:Params({ foo = 'bar', baz = 'bang'})
-- An example of a HTTP POST
HTTP:POST('https://example.com', params, function (status, res)
if status == 200 then
print(res)
end
end)
```
--------------------------------
### TTT Function Usage Example
Source: https://docs.tinkr.site/Routine/Conditions/ttt
Demonstrates how to use the ttt function in a conditional statement. The example checks if the time to target for 'pet' to reach 'target' is greater than 3 seconds, implying a need to wait for the pet to get closer.
```lua
if ttt('pet', 'target') > 3 then
-- Let's take a second, let our pet get closer.
end
if ttt('pet', 'target') > 3 then
-- Let's take a second, let our pet get closer.
end
```
--------------------------------
### Slider Component Examples
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Demonstrates the creation of slider components with different configurations. It includes a basic slider ranging from 0% to 100% and a more customized slider with specific min, max, step, and default values, and without percentage display. These sliders are part of a larger UI builder system.
```lua
local SliderGroup = Builder:Group {
title = "Sliders",
content = {
Builder:Rows {
Builder:Columns {
Builder:Slider {
key = 'slider_a',
label = "Example Slider A",
description = "This slider ranges from 0% (0) to 100% (1).",
},
Builder:Slider {
key = 'slider_b',
label = "Example Slider B",
description = "This slider ranges from 25 to 75.",
min = 25,
max = 75,
step = 1,
default = 50,
percent = false
}
}
}
}
}
```
--------------------------------
### Lua: Multi-Line Edit Box Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Demonstrates the implementation of multi-line text input fields using Tinkr's GUI builder. These are suitable for longer text entries such as comments or descriptions. The example shows how to configure the number of lines, placeholder text, and include an optional button.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local MultiLineEditBoxGroup = Builder:Group {
title = "Multi-Line EditBoxes",
content = {
Builder:Rows {
Builder:Columns {
Builder:EditBox {
key = "multi_editbox_a",
label = "Edit Box A",
multiline = true,
lines = 6,
placeholder = "Placeholder value",
description = "This is a multi-line edit box.",
button = true,
},
Builder:EditBox {
key = "multi_editbox_b",
label = "Edit Box B",
multiline = true,
lines = 6,
placeholder = "Placeholder value",
description = "This is a multi-line edit box."
}
}
}
}
}
```
--------------------------------
### Create Simple Checkboxes
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Implements basic checkboxes with labels and optional descriptions. These are used for binary state selections (e.g., enabling/disabling features).
```lua
local SimpleCheckboxes = Builder:Group {
title = "Simple Checkboxes",
content = {
Builder:Text "Checkboxes allow you to have 2 states (yes and no) which can be used for enabling or disabling functionality.",
Builder:Spacer { },
Builder:Checkbox {
key = "checkbox_a",
label = "Checkbox A",
description = "Description for Checkbox A."
},
Builder:Checkbox {
key = "checkbox_b",
label = "Checkbox B",
description = "Description for Checkbox B."
},
Builder:Checkbox {
key = "checkbox_c",
label = "Checkbox C"
}
}
}
```
--------------------------------
### Deprecated HTTP Helper Methods (GET, POST)
Source: https://docs.tinkr.site/Modules/Util/HTTP
These methods are older convenience functions for making GET and POST requests. They are deprecated and should not be used in new code.
```APIDOC
## Deprecated HTTP Helper Methods
### Description
These are older, deprecated helper methods for making basic HTTP GET and POST requests. It is recommended to use the more flexible `HTTP:Request` method instead.
### Method
`HTTP:GET(url, callback)`
### Parameters
- **url** (string) - The URL to fetch.
- **callback** (function) - A function to handle the response (`status`, `res`).
### Request Example (GET)
```lua
HTTP:GET('https://example.com', function (status, res)
if status == 200 then
print(res)
end
end)
```
### Method
`HTTP:POST(url, params, callback)`
### Parameters
- **url** (string) - The URL to send the POST request to.
- **params** (table) - A table of parameters to send as form data. Use `HTTP:Params` to format.
- **callback** (function) - A function to handle the response (`status`, `res`).
### Request Example (POST)
```lua
local params = HTTP:Params({ foo = 'bar', baz = 'bang'})
HTTP:POST('https://example.com', params, function (status, res)
if status == 200 then
print(res)
end
end)
```
### Helper
`HTTP:Params(params_table)`
### Description
Helper function to format a table of parameters for use with `HTTP:POST`.
### Request Example
```lua
local params = HTTP:Params({ foo = 'bar', baz = 'bang'})
```
```
--------------------------------
### Aura Function Example (Lua)
Source: https://docs.tinkr.site/Routine/Conditions/aura
This example demonstrates how to use the 'aura' function in Lua to check if a 'BlazingBarrier' buff is active ('HELPFUL') on the 'player'. If the aura is present, it attempts to cast the 'BlazingBarrier' spell. The example is repeated, highlighting potential redundancy in usage.
```lua
if aura('player', BlazingBarrier, 'HELPFUL') then
return cast(BlazingBarrier, 'player')
end
if aura('player', BlazingBarrier, 'HELPFUL') then
return cast(BlazingBarrier, 'player')
end
```
--------------------------------
### Lua: Single-Line Edit Box Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Showcases the creation of single-line text input fields (edit boxes) using Tinkr's GUI builder. This example includes edit boxes with labels, descriptions, placeholder text, and an optional button. These are suitable for short text inputs like names or search queries.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local SingleLineEditBoxGroup = Builder:Group {
title = "Single Line EditBoxes",
content = {
Builder:EditBox {
key = "editbox_a",
label = "Edit Box A",
description = "This editbox has a description with it."
},
Builder:EditBox {
key = "editbox_b",
label = "Edit Box B",
placeholder = "This editbox has a placeholder value"
},
Builder:EditBox {
key = "editbox_c",
label = "Edit Box C",
placeholder = "Placeholder Value",
description = "This input requires you to click " .. OKAY,
button = true
}
}
}
```
--------------------------------
### Lua: Radio Button Group Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Demonstrates the implementation of radio button groups using Tinkr's GUI builder. Radio buttons allow users to select one option from a predefined set. This example shows both inline and stacked radio button layouts with custom option labels.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local RadioCheckboxes = Builder:Group {
title = "Radio Checkboxes",
content = {
Builder:Text "Radios allow you to select between a set of options, much like a dropdown but presented in a different way.",
Builder:Spacer { },
Builder:Radio {
key = "radio_a",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D"
}
},
Builder:Spacer { },
Builder:Text "You can also force radios to be stacked instead of displayed inline.",
Builder:Spacer { height = 14 },
Builder:Radio {
key = "radio_b",
stacked = true,
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D"
}
}
}
}
```
--------------------------------
### Lua: Tri-State Checkbox Implementation with Tinkr
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Illustrates the use of tri-state checkboxes in Tinkr's GUI builder. These checkboxes support three states: 'yes', 'no', and 'half', which are useful for indicating partial states. The example shows how to set the default state for each tri-state checkbox.
```lua
local Tinkr = ...
local Builder = Tinkr.Util.GUIBuilder:New {
config = "example_builder"
}
local TriStateCheckboxes = Builder:Group {
title = "Tri State Checkboxes",
content = {
Builder:Text "Tri State checkboxes allow you to have 3 states (yes, no and half) which can be useful for showing that something is partially enabled.",
Builder:Spacer { },
Builder:Checkbox {
tristate = true,
key = "tribox_a",
label = "Tri State A",
default = "yes"
},
Builder:Checkbox {
tristate = true,
key = "tribox_b",
label = "Tri State B",
default = "half"
},
Builder:Checkbox {
tristate = true,
key = "tribox_c",
label = "Tri State C",
default = "no"
}
}
}
```
--------------------------------
### Interrupt Channeling Spell Example (Lua)
Source: https://docs.tinkr.site/Routine/Conditions/channeling
Example demonstrating how to cast 'Rebuke' on a target if the target is channeling. This snippet checks the channeling status and conditionally casts a spell.
```Lua
if channeling('target') then
return cast(Rebuke, 'target')
end
```
--------------------------------
### Create Multi-Line Edit Boxes
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Defines a group of multi-line edit boxes with customizable labels, placeholders, and line counts. These are used for capturing larger text inputs from users.
```lua
local MultiLineEditBoxGroup = Builder:Group {
title = "Multi-Line EditBoxes",
content = {
Builder:Rows {
Builder:Columns {
Builder:EditBox {
key = "multi_editbox_a",
label = "Edit Box A",
multiline = true,
lines = 6,
placeholder = "Placeholder value",
description = "This is a multi-line edit box.",
button = true,
},
Builder:EditBox {
key = "multi_editbox_b",
label = "Edit Box B",
multiline = true,
lines = 6,
placeholder = "Placeholder value",
description = "This is a multi-line edit box.",
}
}
}
}
}
```
--------------------------------
### Configure Radio Button Groups
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Sets up radio button groups for selecting one option from a predefined set. Supports both inline and stacked layouts, with options defined by key-value pairs.
```lua
local RadioCheckboxes = Builder:Group {
title = "Radio Checkboxes",
content = {
Builder:Text "Radios allow you to select between a set of options, much like a dropdown but presented in a different way.",
Builder:Spacer { },
Builder:Radio {
key = "radio_a",
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D"
}
},
Builder:Spacer { },
Builder:Text "You can also force radios to be stacked instead of displayed inline.",
Builder:Spacer { height = 14 },
Builder:Radio {
key = "radio_b",
stacked = true,
values = {
option_a = "Option A",
option_b = "Option B",
option_c = "Option C",
option_d = "Option D"
}
}
}
}
```
--------------------------------
### Specific Channeling Spell Check Example (Lua)
Source: https://docs.tinkr.site/Routine/Conditions/channeling
Example showing how to check if a target is specifically channeling the 'Hearth' spell. This allows for targeted interruptions based on the spell name.
```Lua
if channeling('target') == "Hearth" then
return cast(Rebuke, 'target')
end
```
--------------------------------
### ScreenToWorld Function Signature and Example Usage
Source: https://docs.tinkr.site/Lua/Utility/ScreenToWorld
This snippet shows the function signature for ScreenToWorld, which takes screen coordinates (x, y) and hit flags to return world coordinates (x, y, z). It also includes an example demonstrating how to call the function with sample values and bitwise OR operations for hit flags.
```lua
ScreenToWorld(x, y, hitFlags) : x, y, z
ScreenToWorld(x, y, hitFlags) : x, y, z
```
```lua
local sx, sy = 0, 0
local hitFlags = bit.bor(0x1, 0x10, 0x100, 0x100000)
local x, y, z = ScreenToWorld(sx, sy, hitFlags)
local sx, sy = 0, 0
local hitFlags = bit.bor(0x1, 0x10, 0x100, 0x100000)
local x, y, z = ScreenToWorld(sx, sy, hitFlags)
```
--------------------------------
### Create Single Line Edit Boxes
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Defines single-line input fields with labels, descriptions, and placeholder text. An optional button can be appended to the edit box.
```lua
local SingleLineEditBoxGroup = Builder:Group {
title = "Single Line EditBoxes",
content = {
Builder:EditBox {
key = "editbox_a",
label = "Edit Box A",
description = "This editbox has a description with it."
},
Builder:EditBox {
key = "editbox_b",
label = "Edit Box B",
placeholder = "This editbox has a placeholder value"
},
Builder:EditBox {
key = "editbox_c",
label = "Edit Box C",
placeholder = "Placeholder Value",
description = "This input requires you to click " .. OKAY,
button = true
}
}
}
```
--------------------------------
### Implement Tri-State Checkboxes
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Creates checkboxes with three states: 'yes', 'no', and 'half'. Useful for representing partial states, such as a setting that is partially enabled.
```lua
local TriStateCheckboxes = Builder:Group {
title = "Tri State Checkboxes",
content = {
Builder:Text "Tri State checkboxes allow you to have 3 states (yes, no and half) which can be useful for showing that something is partially enabled.",
Builder:Spacer { },
Builder:Checkbox {
tristate = true,
key = "tribox_a",
label = "Tri State A",
default = "yes"
},
Builder:Checkbox {
tristate = true,
key = "tribox_b",
label = "Tri State B",
default = "half"
},
Builder:Checkbox {
tristate = true,
key = "tribox_c",
label = "Tri State C",
default = "no"
}
}
}
```
--------------------------------
### Use Healthstone
Source: https://docs.tinkr.site/Routine/Conditions/clickitem
Provides an example of using a Healthstone on the player, demonstrating item usage.
```APIDOC
## POST /websites/tinkr_site/use_healthstone
### Description
Checks if the player has a Healthstone and, if so, uses it on the player. This is an example snippet.
### Method
POST
### Endpoint
/websites/tinkr_site/use_healthstone
### Parameters
None directly for this endpoint, logic is within the example.
### Request Body
None
### Response
#### Success Response (200)
- **used** (boolean) - Indicates if the Healthstone was used.
#### Response Example
```json
{
"used": true
}
```
```
--------------------------------
### TraceLine Example: Check Line of Sight
Source: https://docs.tinkr.site/Lua/Utility/TraceLine
An example demonstrating how to use the TraceLine function to check the line of sight between two objects. It retrieves object positions, sets hit flags using bitwise OR operations, and then calls TraceLine.
```lua
local x1, y1, z1 = ObjectPosition('player')
local x2, y2, z2 = ObjectPosition('target')
local hitFlags = bit.bor(0x1, 0x10, 0x100, 0x100000)
local x, y, z = TraceLine(x1, y1, z1, x2, y2, z2, hitFlags)
```
--------------------------------
### Example of Using Click Item with Item Check (Tinkr Script - Placeholder)
Source: https://docs.tinkr.site/Routine/Conditions/clickitem
A placeholder example demonstrating how the clickitem function might be used in conjunction with checking for item availability. This pseudocode indicates a conditional use of the 'use' function based on item presence, intended to be replaced with actual code.
```Tinkr Script
-- if items(HealthStone) >= 0 then
-- return use(Healthstone, 'player')
-- end
-- if items(HealthStone) >= 0 then
-- return use(Healthstone, 'player')
-- end
```
--------------------------------
### Embed HTML Content
Source: https://docs.tinkr.site/Modules/Util/GUI%20Builder/examples
Includes raw HTML content within the UI, allowing for rich text formatting, images, and links. This is useful for displaying static information or styled text.
```html
local HTMLTypographyGroup = Builder:SimpleGroup {
Builder:HTML [[
This is a paragraph element. It contains text.
This is yes another paragraph element. It contains even more text.
This is a link, clicking it will open the URL in your browser.