### Full Example Script Source: https://scripting.flarial.xyz/getting-started/first_script This is the complete Lua script combining metadata, a toggle setting, and event handling for the 'Hello World' example. ```lua name = "Hello World" description = "Your first Flarial script" gg = settings.addToggle("Auto GG", "Automatically says GG", false) onEvent("ChatReceiveEvent", function(message, name, type) if not gg.value then return end if message == "won the game" then player.say("gg") end end) ``` -------------------------------- ### Setting Up Autocomplete for Flarial Source: https://scripting.flarial.xyz/getting-started/prerequisites This guide explains how to enable autocompletion for Flarial scripting in Visual Studio Code. It involves injecting Flarial, installing autocomplete files, and configuring the Lua extension's user third-party path. ```apidoc Flarial Autocomplete Setup: 1. Inject Flarial and execute `.lua autocomplete` in chat to install autocomplete files. 2. Open Visual Studio Code. 3. Navigate to Extensions > Lua extension settings. 4. Locate and modify the 'User Third Party' setting. 5. Add the following directory path: %localappdata%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState\Flarial\Scripts\AutoComplete 6. Save the settings. Important Note: Ensure the entire 'Scripts' folder is opened in VS Code for autocompletion to function correctly. ``` -------------------------------- ### Basic Functionality with onEnable Source: https://scripting.flarial.xyz/getting-started/first_script The `onEnable()` function is executed when the script module is enabled. This example prints a message to the chat. ```lua function onEnable() print("Hello, World!") end ``` -------------------------------- ### Listening for Events and Using Settings Source: https://scripting.flarial.xyz/getting-started/first_script Scripts can listen for specific game events using `onEvent`. This example listens for `ChatReceiveEvent` and uses the `gg` setting to conditionally send a chat message. ```lua onEvent("ChatReceiveEvent", function(message, name, type) if not gg.value then return end if message == "won the game" then player.say("gg") end end) ``` -------------------------------- ### ImGui Window Management Functions Source: https://scripting.flarial.xyz/api/imgui/imgui Provides functions for managing ImGui windows, including starting, ending, and configuring window properties. This includes creating new windows, child windows, popups, and setting window behavior like size, position, and focus. ```APIDOC ImGui.Begin(name: str, p_open: bool = None, flags: int = 0) Begins a new ImGui window. Returns true if the window is visible. Parameters: name: The unique name of the window. p_open: Optional pointer to a boolean that determines if the window should be collapsed. flags: Window flags to control behavior. ImGui.End() Ends the current ImGui window. ImGui.BeginChild(str_id: str, size: tuple = (0, 0), border: bool = False, flags: int = 0) Begins a child window. Returns true if the child window is visible. Parameters: str_id: The unique identifier for the child window. size: The desired size of the child window. border: Whether to draw a border around the child window. flags: Child window flags. ImGui.BeginChildID(id: int, size: tuple = (0, 0), border: bool = False, flags: int = 0) Begins a child window using an integer ID. Parameters: id: The unique integer identifier for the child window. size: The desired size of the child window. border: Whether to draw a border around the child window. flags: Child window flags. ImGui.BeginChildFrame(id: int, size: tuple, flags: int = 0) Begins a child window with a frame. Returns true if the frame is visible. Parameters: id: The unique integer identifier for the child frame. size: The size of the child frame. flags: Child frame flags. ImGui.BeginPopup(popup_id: str, flags: int = 0) Begins a modal or regular popup. Returns true if the popup is visible. Parameters: popup_id: The unique identifier for the popup. flags: Popup flags. ImGui.BeginPopupContextItem(popup_id: str = None, mouse_button: int = 1) Begins a popup context menu for the current item. Parameters: popup_id: Optional unique identifier for the popup. mouse_button: The mouse button to trigger the popup. ImGui.BeginPopupContextVoid(popup_id: str = None, mouse_button: int = 1) Begins a popup context menu for the void (empty space). Parameters: popup_id: Optional unique identifier for the popup. mouse_button: The mouse button to trigger the popup. ImGui.BeginTabBar(str_id: str, flags: int = 0) Begins a tab bar. Returns true if the tab bar is visible. Parameters: str_id: The unique identifier for the tab bar. flags: Tab bar flags. ImGui.BeginTable(str_id: str, column: int, flags: int = 0, outer_size: tuple = (0, 0), inner_width: float = 0.0) Begins a table. Returns true if the table is visible. Parameters: str_id: The unique identifier for the table. column: The number of columns in the table. flags: Table flags. outer_size: The outer size of the table. inner_width: The inner width of the table. ImGui.BeginTooltip() Begins a tooltip. ImGui.CloseCurrentPopup() Closes the current popup. ImGui.SetNextWindowSize(size: tuple, cond: int = 0) Sets the size of the next window. Parameters: size: The desired size (width, height). cond: Condition for setting the size. ImGui.SetNextWindowPos(pos: tuple, cond: int = 0, pivot: tuple = (0.0, 0.0)) Sets the position of the next window. Parameters: pos: The desired position (x, y). cond: Condition for setting the position. pivot: The pivot point for positioning. ImGui.SetNextWindowBgAlpha(alpha: float) Sets the background alpha of the next window. Parameters: alpha: The background alpha value (0.0 to 1.0). ImGui.SetNextWindowCollapsed(collapsed: bool, cond: int = 0) Sets the collapsed state of the next window. Parameters: collapsed: True to collapse, false to expand. cond: Condition for setting the collapsed state. ImGui.SetNextWindowFocus() Sets the focus for the next window. ImGui.SetNextWindowContentSize(size: tuple) Sets the content size of the next window. Parameters: size: The desired content size (width, height). ``` -------------------------------- ### Setup and Render Event Handling Source: https://scripting.flarial.xyz/api/game/events Provides a faster loop than TickEvent and allows safe access to player functions. Rendering ImGui or FlarialGUI is not safe in this event. ```lua onEvent("SetupAndRenderEvent", function() end) ``` -------------------------------- ### ImGui Window Management Source: https://scripting.flarial.xyz/api/imgui/imgui Functions for managing ImGui windows, including starting, ending, and creating child windows or frames. These functions are essential for structuring the UI. ```APIDOC ImGui.Begin(name) - Begins a new ImGui window. - Parameters: - name: string: The window name. - Returns: - nil: ImGui.End() - Ends the current ImGui window. - Returns: - nil: ImGui.BeginChild(name, size, child_flags, window_flags) - Begins a child window. - Parameters: - name: string: The child window name. - size: table: The size of the child window, in pixels. Format: - child_flags: boolean|nil: ImGuiChildFlags. - window_flags: number|nil: ImGuiWindowFlags. - Returns: - nil: ImGui.BeginChildID(id, size, child_flags, window_flags) - Begins a child window using an ID. - Parameters: - id: number: The ImGui ID. - size: table: The size of the child window, in pixels. Format: - child_flags: number|nil: ImGuiChildFlags. - window_flags: number|nil: ImGuiWindowFlags. - Returns: - nil: ImGui.BeginChildFrame(id, size, flags) - Begins a child frame. - Parameters: - id: number: The ImGui ID. - size: table: The size of the frame, in pixels. Format: - flags: number|nil: ImGuiWindowFlags. - Returns: - nil: ``` -------------------------------- ### ImGui Text and Button Functions Source: https://scripting.flarial.xyz/api/imgui/imgui This section documents ImGui functions for displaying text elements and interactive buttons. It includes `BeginTooltip` for starting a tooltip, `Bullet` for displaying a bullet point, `BulletText` for text with a bullet, and `Button` for creating clickable buttons. Parameter details, return types (nil for text functions, boolean for buttons), and usage are provided. ```APIDOC ImGui.BeginTooltip() Begins a tooltip. Returns: nil: ImGui.Bullet() Displays a bullet point. Returns: nil: ImGui.BulletText(text) Displays bullet text. Parameters: text: string: The text to display. Returns: nil: ImGui.Button(label, size) Creates a button. Parameters: label: string: The button label. size: table|nil: The size of the button, in pixels. Format: Returns: boolean: True if the button was pressed. ``` -------------------------------- ### ImGui Input Handling Source: https://scripting.flarial.xyz/api/imgui/imgui Functions to check the state of keyboard keys and mouse buttons, including release and click events, and to get mouse position and display size. ```APIDOC ImGui.IsKeyReleased(key) - Checks if a key has been released. - Parameters: - key: The key code. - Returns: - boolean: True if the key is released. ImGui.IsMouseDown(button) - Checks if a mouse button is down. - Parameters: - button: The mouse button. - Returns: - boolean: True if the button is down. ImGui.IsMouseClicked(button) - Checks if a mouse button has been clicked. - Parameters: - button: The mouse button. - Returns: - boolean: True if the button is clicked. ImGui.IsMouseReleased(button) - Checks if a mouse button has been released. - Parameters: - button: The mouse button. - Returns: - boolean: True if the button is released. ImGui.GetMousePos() - Gets the current mouse position. - Returns: - table: The mouse position {x, y}. ImGui.GetDisplaySize() - Gets the display size. - Returns: - table: The display size {width, height}. ImGui.GetFrameRate() - Gets the current frame rate. - Returns: - number: The frame rate. ImGui.GetDeltaTime() - Gets the time elapsed since the last frame. - Returns: - number: The delta time. ``` -------------------------------- ### ImGui Drawing List Functions Source: https://scripting.flarial.xyz/api/imgui/imgui Provides access to ImGui's drawing lists, allowing for custom drawing operations. This includes getting draw lists for the background, foreground, and current window, enabling advanced rendering capabilities. ```APIDOC ImGui.GetBackgroundDrawList() Gets the draw list for the background. ImGui.GetForegroundDrawList() Gets the draw list for the foreground. ImGui.GetWindowDrawList() Gets the draw list for the current window. ImGui.GetDrawData() Gets the draw data for the current frame. ``` -------------------------------- ### ImGui Display Size Source: https://scripting.flarial.xyz/api/imgui/imgui Gets the dimensions of the Minecraft window in pixels. Returns a Vector2 object representing width and height. ```APIDOC ImGui.GetDisplaySize(): Vector2 Returns: Vector2: the width and height of the window in pixels. ``` -------------------------------- ### Network GET Request Source: https://scripting.flarial.xyz/api/client/network Sends an HTTP GET request to a specified URL. It takes the URL as a string parameter and returns the server's response body as a string. ```APIDOC network.get(url: string) -- Sends an HTTP GET request to the specified URL. -- Parameters: -- url: string - The URL to send the request to. -- Returns: -- string: The response body from the server. ``` -------------------------------- ### ImGui API Documentation Source: https://scripting.flarial.xyz/api/imgui/imgui Provides comprehensive documentation for the ImGui API, including its methods, parameters, and usage within the scripting environment. This section details the functionalities related to GUI rendering and interaction through ImGui. ```APIDOC ImGui API: This API provides access to the ImGui library for creating graphical user interfaces within the scripting environment. Modules: - drawlist: For drawing operations within ImGui. - imgui: Core ImGui functionalities. Related Modules: - gui: General GUI functionalities. - constraints: For defining GUI layout constraints. ``` -------------------------------- ### Get Player Dimension Source: https://scripting.flarial.xyz/api/game/player Returns the player's current dimension as a string. Returns 'unknown' if the dimension cannot be determined. ```lua function player.dimension() end ``` -------------------------------- ### Client API Documentation Source: https://scripting.flarial.xyz/api/client/client Provides a comprehensive reference for the client API, including function signatures, parameter descriptions, and return values. This API allows interaction with the game client for various functionalities. ```APIDOC client.notify(message) - Displays a notification on your screen. - Parameters: - message: string: The notification message. - Returns: - nil: client.crash() - Crashes the game. - Returns: - nil: client.freeMouse() - Frees your mouse. - Returns: - nil: client.grabMouse() - Grabs your mouse. - Returns: - nil: client.getScreenName() - Returns the current screen name. - Returns: - string: The screen name. ``` -------------------------------- ### Get Player Rotation Source: https://scripting.flarial.xyz/api/game/player Returns the player's current rotation as a Vector2 object. Defaults to (0.0f, 0.0f) if the player is unavailable. ```lua function player.rotation() end ``` -------------------------------- ### Define Script Metadata Source: https://scripting.flarial.xyz/getting-started/first_script All Flarial scripts require a name and description to be loaded correctly. These are defined as global variables at the top of the script. ```lua name = "Hello World" description = "Your first Flarial script" ``` -------------------------------- ### ImGui Menu and Popup Functions Source: https://scripting.flarial.xyz/api/imgui/imgui This section details ImGui functions for managing menus and popups. It includes functions to begin main menu bars, regular menus, and various types of popups (contextual, void, and general). Each function specifies its parameters and return values, indicating whether the menu or popup was successfully opened or activated. ```APIDOC ImGui.BeginMainMenuBar() Begins the main menu bar. Returns: boolean: True if the main menu bar is active. ImGui.BeginMenu(name, enabled) Begins a menu. Parameters: name: string: The menu name. enabled: boolean|nil: Whether the menu is enabled. Returns: boolean: True if the menu is open. ImGui.BeginPopup(name, flags) Begins a popup window. Parameters: name: string: The popup window name. flags: number|nil: ImGuiWindowFlags. Returns: boolean: True if the popup began. ImGui.BeginPopupContextItem(name, flags) Begins a context popup for an item. Parameters: name: string|nil: The context popup name. flags: number|nil: ImGuiPopupFlags. Returns: boolean: True if the context popup began. ImGui.BeginPopupContextVoid(name, flags) Begins a context popup for a void area. Parameters: name: string|nil: The context popup name. flags: number|nil: ImGuiPopupFlags. Returns: boolean: True if the context popup began. ``` -------------------------------- ### ImGui Table and Tab Bar Functions Source: https://scripting.flarial.xyz/api/imgui/imgui This section covers ImGui functions for creating and managing tab bars and tables. It includes `BeginTabBar` for initiating a tab bar and `BeginTable` for creating tables with specified columns and sizes. The documentation outlines the parameters required for each, such as names, flags, column counts, and size specifications, along with their boolean return values indicating success. ```APIDOC ImGui.BeginTabBar(name, flags) Begins a tab bar. Parameters: name: string: The tab bar name. flags: number|nil: ImGuiTabBarFlags. Returns: boolean: True if the tab bar began. ImGui.BeginTable(name, column, outer_size, inner_width) Begins a table. Parameters: name: string: The table name. column: number: Number of columns. outer_size: table: The outer size, in pixels. Format: inner_width: number|nil: The inner width. Returns: boolean: True if the table began. ``` -------------------------------- ### Get Player Mainhand Item Data Source: https://scripting.flarial.xyz/api/game/player Retrieves data for the item currently held in the player's mainhand. If no item is present or the item piece doesn't exist, default values (-1 for numerical properties, 'empty' for name) are returned. ```lua function player.mainhand() end ``` -------------------------------- ### ImGui Window Positioning and Sizing Source: https://scripting.flarial.xyz/api/imgui/imgui Functions to set the size and position of the next window to be created. `SetNextWindowSize` takes a size table and optional flags, while `SetNextWindowPos` takes a position table and an optional pivot. ```lua function ImGui.SetNextWindowSize(size, flags) end function ImGui.SetNextWindowPos(pos, pivot) end ``` -------------------------------- ### Get Player Offhand Item Data Source: https://scripting.flarial.xyz/api/game/player Retrieves data for the item currently held in the player's offhand. If no item is present or the item piece doesn't exist, default values (-1 for numerical properties, 'empty' for name) are returned. ```lua function player.offhand() end ``` -------------------------------- ### ImGui.ColorButton Source: https://scripting.flarial.xyz/api/imgui/imgui Creates a color button that displays a color swatch. It requires a description ID and color, with an optional size parameter. Returns true if the button is pressed. ```lua function ImGui.ColorButton(desc_id, color, size) end ``` -------------------------------- ### Adding a Toggle Setting Source: https://scripting.flarial.xyz/getting-started/first_script Settings can be added to scripts to allow user configuration. The `settings.addToggle` function creates a boolean toggle with a name, description, and a default value. ```lua gg = settings.addToggle("Auto GG", "Automatically says GG", false) ``` -------------------------------- ### GUI Settings API Source: https://scripting.flarial.xyz/api/gui/settings This section details the functions available in the GUI settings module for customizing the ClickGUI. It covers adding various UI elements and their configurations. ```APIDOC settings.addHeader(name) Adds a new Header to the ClickGUI. Parameters: name: string: The header text. settings.extraPadding() Adds extra padding to the ClickGUI. settings.addToggle(name, desc, defValue) Adds a toggle setting to the ClickGUI. Parameters: name: string: The setting name. desc: string: The setting description. defValue: boolean: The default value. Returns: BoolSetting: The created setting object with a `value` field. settings.addSlider(name, desc, defValue, maxValue, minValue, zerosafe) Adds a slider setting to the ClickGUI. Parameters: name: string: The setting name. desc: string: The setting description. defValue: number: The default value. maxValue: number: The maximum slider value. minValue: number: The minimum slider value. zerosafe: boolean|nil: Whether the slider allows zero as a valid value (default is true if omitted). Returns: SliderSetting: The created setting object with a `value` field. settings.addTextBox(name, desc, defaultValue, limit) Adds a text box setting to the ClickGUI. Parameters: name: string: The setting name. desc: string: The setting description. defaultValue: string: The default text box value. limit: number: The maximum character limit for the text box. ``` -------------------------------- ### ImGui.Text Source: https://scripting.flarial.xyz/api/imgui/imgui Displays a static text string. This function takes the text content as a parameter and returns nil. ```lua function ImGui.Text(text) end ``` -------------------------------- ### GUI Constraints API Documentation Source: https://scripting.flarial.xyz/api/gui/constraints Provides detailed documentation for the Constraints class, including functions for calculating UI element properties like percentage-based sizing, relative dimensions, and centering. This API is crucial for responsive UI design in the scripting environment. ```APIDOC Constraints.PercentageConstraint: __call(percentage, edge, ignore_stack) Computes a value based on a percentage of a specified edge’s dimension. Parameters: percentage (number): The percentage value (e.g. 0.5 for 50%). edge (string): The edge identifier (e.g. "left", "right", etc.). ignore_stack (boolean|nil): Ignores any stacking effects. Returns: number: The computed value. Constraints.RelativeConstraint: __call(percent, dimension, ignore_stack) Computes a relative value based on a percentage of a given dimension. Parameters: percent (number): The percentage value (e.g. 0.5 for 50%). dimension (string|nil): The dimension to base the calculation on. ignore_stack (boolean|nil): Ignores any stacking effects. Returns: number: The computed relative value. Constraints.CenterConstraint: __call(width, height, axis, xModifier, yModifier, ignore_stack) Calculates the center coordinates for a rectangle. Parameters: width (number): The width of the rectangle. height (number): The height of the rectangle. axis (string|nil): Axis specification. xModifier (number|nil): Modifier for the x-coordinate. yModifier (number|nil): Modifier for the y-coordinate. ignore_stack (boolean|nil): Ignores any stacking effects. Returns: Vector2: Returns a vector2 representing the center coordinates. ``` -------------------------------- ### ImGui Draw List Accessors Source: https://scripting.flarial.xyz/api/imgui/imgui Provides access to different draw lists for rendering ImGui elements. These include the background, foreground, and current window draw lists. ```lua function ImGui.GetBackgroundDrawList() end function ImGui.GetForegroundDrawList() end function ImGui.GetWindowDrawList() end ``` -------------------------------- ### ImDrawList API Reference Source: https://scripting.flarial.xyz/api/imgui/drawlist This section provides a comprehensive reference for the ImDrawList API, detailing methods for drawing various graphical elements. It includes function signatures, parameter descriptions, and return values. ```APIDOC ImDrawList:AddCircle(center, radius, color, numSegments, thickness) Adds a circle outline. Parameters: center: table: The center of the circle. radius: number: The radius. color: table: The circle color. numSegments: number|nil: Number of segments. thickness: number|nil: The outline thickness. Returns: nil: ImDrawList:AddCircleFilled(center, radius, color, numSegments) Adds a filled circle. Parameters: center: table: The center of the circle. radius: number: The radius. color: table: The fill color. numSegments: number|nil: Number of segments. Returns: nil: ImDrawList:AddText(pos, color, font_size, text) Adds text to the draw list with a custom font size. Parameters: pos: table: {x, y} The position of the text. color: table: {r, g, b, a} The text color (RGBA format, 0-255). font_size: number: The font size in pixels. text: string: The text to display. Returns: nil: ImDrawList:AddTriangleFilled(p1, p2, p3, color) Adds a filled triangle. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. color: table: The fill color. Returns: nil: ImDrawList:AddTriangle(p1, p2, p3, color, thickness) Adds a triangle outline. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. color: table: The triangle color. thickness: number: The line thickness. Returns: nil: ImDrawList:AddQuadFilled(p1, p2, p3, p4, color) Adds a filled quadrilateral. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. p4: table: The fourth vertex. color: table: The fill color. Returns: nil: ImDrawList:AddQuad(p1, p2, p3, p4, color, thickness) Adds a quadrilateral outline. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. p4: table: The fourth vertex. color: table: The quad color. thickness: number: The line thickness. Returns: nil: ``` -------------------------------- ### ImGui.SameLine Source: https://scripting.flarial.xyz/api/imgui/imgui Allows subsequent UI elements to be drawn on the same horizontal line as the previous element. It accepts optional offset and spacing parameters. ```lua function ImGui.SameLine(offset, spacing) end ``` -------------------------------- ### Add Slider Setting to ClickGUI Source: https://scripting.flarial.xyz/api/gui/settings Adds a slider setting to the ClickGUI with specified parameters. Returns a SliderSetting object. ```lua function settings.addSlider(name, desc, defValue, maxValue, minValue, zerosafe) end ``` -------------------------------- ### fs Class API Documentation Source: https://scripting.flarial.xyz/api/misc/fs Provides comprehensive documentation for the 'fs' class, including methods for file system operations. This includes checking for file/directory existence, creating and removing files/directories, reading file content, writing to files, and listing directory contents. ```APIDOC fs Class: Provides file system operations. fs.exists(path) Checks if the specified path exists. Parameters: path: string - The file path relative to the Flarial folder. Returns: boolean - True if the path exists. fs.isDirectory(path) Checks if the specified path is a directory. Parameters: path: string - The file path relative to the Flarial folder. Returns: boolean - True if the path is a directory. fs.create(path) Creates a directory at the specified path. Parameters: path: string - The directory path relative to the Flarial folder. Returns: boolean - True if the directory was successfully created. fs.remove(path) Removes the file or directory at the specified path. Parameters: path: string - The file or directory path relative to the Flarial folder. Returns: boolean - True if removal was successful. fs.readFile(path) Reads the contents of a file at the specified path. Parameters: path: string - The file path relative to the Flarial folder. Returns: string - The file’s content. fs.writeFile(path, content) Writes content to the file at the specified path. Parameters: path: string - The file path relative to the Flarial folder. content: string - The content to write. Returns: boolean - True if writing was successful. fs.listDirectory(path) Lists the contents of a directory at the specified path. Parameters: path: string - The directory path relative to the Flarial folder. Returns: table - A table containing the names of files and subdirectories. ``` -------------------------------- ### Add Extra Padding to ClickGUI Source: https://scripting.flarial.xyz/api/gui/settings Adds extra padding to the ClickGUI. ```lua function settings.extraPadding() end ``` -------------------------------- ### Add Toggle Setting to ClickGUI Source: https://scripting.flarial.xyz/api/gui/settings Adds a toggle setting to the ClickGUI with a name, description, and default value. Returns a BoolSetting object. ```lua function settings.addToggle(name, desc, defValue) end ``` -------------------------------- ### Add Textbox Setting Source: https://scripting.flarial.xyz/api/gui/settings Adds a textbox setting to the ClickGUI. This function allows customization of the textbox with a name, description, default value, and character limit. ```APIDOC settings.addTextbox(name: string, desc: string, defaultValue: string, limit: number) - Adds a textbox setting to the ClickGUI. - Parameters: - name: The setting name. - desc: The setting description. - defaultValue: The default text inside the textbox. - limit: The maximum number of characters allowed in the textbox. - Returns: - TextBoxSetting: The created setting object with a `value` field. ``` -------------------------------- ### Util API Documentation Source: https://scripting.flarial.xyz/api/misc/util Provides documentation for utility functions related to key codes and clipboard operations. ```APIDOC util.keyToString(key) Converts a key code to its string representation. Parameters: key: number: The key code. Returns: string: The key as a string. util.setClipboard(text) Sets the clipboard content. Parameters: text: string: The text to set in the clipboard. Returns: nil: util.getClipboard() Gets the current clipboard content. Returns: string: The clipboard text. ``` -------------------------------- ### Add Header to ClickGUI Source: https://scripting.flarial.xyz/api/gui/settings Adds a new header to the ClickGUI with the specified name. ```lua function settings.addHeader(name) end ``` -------------------------------- ### ImGui Widget Functions Source: https://scripting.flarial.xyz/api/imgui/imgui Provides functions for creating various ImGui widgets such as buttons, text displays, input fields, and combo boxes. These functions allow for interactive UI elements within the ImGui framework. ```APIDOC ImGui.BeginCombo(label: str, preview_value: str, flags: int = 0) Begins a combo box. Returns true if the combo box is open. Parameters: label: The label for the combo box. preview_value: The currently selected value displayed. flags: Combo box flags. ImGui.BeginDragDropSource(flags: int = 0) Begins a drag and drop source. Returns true if a drag operation is in progress. Parameters: flags: Drag and drop source flags. ImGui.BeginDragDropTarget() Begins a drag and drop target. Returns true if a drag operation is hovering. ImGui.BeginGroup() Begins a group of widgets. ImGui.BeginMainMenuBar() Begins the main menu bar. Returns true if the menu bar is visible. ImGui.BeginMenu(label: str, enabled: bool = True) Begins a menu item. Returns true if the menu is open. Parameters: label: The label for the menu item. enabled: Whether the menu item is enabled. ImGui.Bullet() Displays a bullet point. ImGui.BulletText(text: str) Displays text with a bullet point. Parameters: text: The text to display. ImGui.Button(label: str, size: tuple = (0, 0)) Creates a button. Returns true if the button was clicked. Parameters: label: The text on the button. size: The size of the button. ImGui.CollapsingHeader(label: str, flags: int = 0) Creates a collapsing header. Returns true if the header is open. Parameters: label: The label for the header. flags: Header flags. ImGui.ColorButton(desc_id: str, col: tuple, flags: int = 0, size: tuple = (0, 0)) Creates a color button. Returns true if the button was clicked. Parameters: desc_id: Description identifier for the color button. col: The color (RGBA tuple). flags: Color button flags. size: The size of the color button. ImGui.Text(text: str) Displays plain text. Parameters: text: The text to display. ImGui.InputText(label: str, buf: str, buf_size: int, flags: int = 0, callback: callable = None, user_data: any = None) Creates a text input field. Returns true if the value was changed. Parameters: label: The label for the input field. buf: The buffer to store the input text. buf_size: The size of the buffer. flags: Input text flags. callback: Optional callback function. user_data: User data for the callback. ImGui.SameLine(pos_x: float = 0.0, spacing: float = -1.0) Positions subsequent widgets on the same line. Parameters: pos_x: The x-position to start the line. spacing: The spacing between widgets. ``` -------------------------------- ### ImGui Grouping Source: https://scripting.flarial.xyz/api/imgui/imgui Function for grouping UI elements together within ImGui. ```APIDOC ImGui.BeginGroup() - Begins an ImGui group. - Returns: - nil: ``` -------------------------------- ### Execute Server Command as Player Source: https://scripting.flarial.xyz/api/game/player Executes a server-side command. The command should be provided as a string without the leading '/'. ```lua function player.executeCommand(command) end ``` -------------------------------- ### ImGui.SetNextWindowContentSize Source: https://scripting.flarial.xyz/api/imgui/imgui Sets the content size for the next ImGui window. The size is specified as a table with width and height in pixels. ```lua function ImGui.SetNextWindowContentSize(size) end ``` -------------------------------- ### Add Text Box Setting to ClickGUI Source: https://scripting.flarial.xyz/api/gui/settings Adds a text box setting to the ClickGUI with a name, description, default value, and character limit. ```lua function settings.addTextBox(name, desc, defaultValue, limit) end ``` -------------------------------- ### AddQuad Source: https://scripting.flarial.xyz/api/imgui/drawlist Adds a quadrilateral outline to the draw list. Requires the coordinates of the four vertices, the color of the quadrilateral, and the thickness of the outline. ```lua function ImDrawList:AddQuad(p1, p2, p3, p4, color, thickness) end ``` -------------------------------- ### ImDrawList Drawing Methods Source: https://scripting.flarial.xyz/api/imgui/drawlist This section covers various methods for drawing primitives onto the ImDrawList. These include adding lines, rectangles, circles, and quadrilaterals with options for color, thickness, rounding, and fill. ```APIDOC ImDrawList:AddLine(p1, p2, color, thickness) Adds a line to the draw list. Parameters: p1: table: The starting point. p2: table: The starting point. color: table: The line color. thickness: number|nil: The line thickness. Returns: nil: ImDrawList:AddRect(p1, p2, color, rounding, thickness, flags) Adds a rectangle outline. Parameters: p1: table: The top-left corner. p2: table: The bottom-right corner. color: table: The rectangle color. rounding: number|nil: The corner rounding. thickness: number|nil: The line thickness. flags: ImDrawList|nil: The drawlist flags. Returns: nil: ImDrawList:AddRectFilled(p1, p2, color, rounding, flags) Adds a filled rectangle. Parameters: p1: table: The top-left corner. p2: table: The bottom-right corner. color: table: The fill color. rounding: number|nil: The corner rounding. flags: ImDrawList|nil: The drawlist flags. Returns: nil: ImDrawList:AddCircle(center, radius, color, numSegments, thickness) Adds a circle outline. Parameters: center: table: The center of the circle. radius: number: The radius of the circle. color: table: The circle color. numSegments: number|nil: The number of segments to approximate the circle. thickness: number|nil: The line thickness. Returns: nil: ImDrawList:AddCircleFilled(center, radius, color, numSegments) Adds a filled circle. Parameters: center: table: The center of the circle. radius: number: The radius of the circle. color: table: The fill color. numSegments: number|nil: The number of segments to approximate the circle. Returns: nil: ImDrawList:AddTriangleFilled(p1, p2, p3, color) Adds a filled triangle. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. color: table: The fill color. Returns: nil: ImDrawList:AddTriangle(p1, p2, p3, color, thickness) Adds a triangle outline. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. color: table: The line color. thickness: number|nil: The line thickness. Returns: nil: ImDrawList:AddQuadFilled(p1, p2, p3, p4, color) Adds a filled quadrilateral. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. p4: table: The fourth vertex. color: table: The fill color. Returns: nil: ImDrawList:AddQuad(p1, p2, p3, p4, color, thickness) Adds a quadrilateral outline. Parameters: p1: table: The first vertex. p2: table: The second vertex. p3: table: The third vertex. p4: table: The fourth vertex. color: table: The line color. thickness: number|nil: The line thickness. Returns: nil: ImDrawList:AddText(pos, text_color, text) Adds text to the draw list. Parameters: pos: table: The position of the text. text_color: table: The color of the text. text: string: The text to draw. Returns: nil: ``` -------------------------------- ### Add Keybind Setting Source: https://scripting.flarial.xyz/api/gui/settings Adds a keybind setting to the ClickGUI. Note that default values are not supported for keybinds due to Flarial's handling of keybinds. ```lua function settings.addKeybind(name, desc) end ``` ```APIDOC settings.addKeybind(name: string, desc: string) - Adds a keybind setting to the ClickGUI. - Due to how keybinds are handled in Flarial, default values do not work. - Parameters: - name: The setting name. - desc: The setting description. - Returns: - KeybindSetting: The created setting object with a `value` field. ``` -------------------------------- ### ImGui Combo Box and Drag-Drop Source: https://scripting.flarial.xyz/api/imgui/imgui Functions for creating combo boxes and handling drag-and-drop operations. These are used for interactive UI elements. ```APIDOC ImGui.BeginCombo(name, previewValue, flags) - Begins a combo box. - Parameters: - name: string: The combo box name. - previewValue: string: The preview value to display. - flags: number|nil: ImGuiComboFlags. - Returns: - boolean: True if the combo box is open. ImGui.BeginDragDropSource(flags) - Begins a drag and drop source. - Parameters: - flags: number|nil: ImGuiDragDropFlags. - Returns: - boolean: True if the drag and drop source has begun. ImGui.BeginDragDropTarget() - Begins a drag and drop target. - Returns: - boolean: True if a drag and drop target is available. ``` -------------------------------- ### ImGui.SetNextWindowFocus Source: https://scripting.flarial.xyz/api/imgui/imgui Sets the focus to the next ImGui window that is created or updated. This function does not take any parameters. ```lua function ImGui.SetNextWindowFocus() end ``` -------------------------------- ### Script Metadata Source: https://scripting.flarial.xyz/api/script Defines metadata for a script, including its name, description, author, and debug mode. ```APIDOC name: string The name of the module/command (required). Spaces are not allowed in command names. Example: name = "Flarial" description: string The description of the module/command (required). Example: description = "Flarial Description" author: string The name of the module/command's author (optional). Used to display credits for the script creator. Example: author = "skinStandardCust" debug: boolean Enables or disables debug mode (optional). When true, error messages will include full stack tracebacks. Example: debug = true ``` -------------------------------- ### GUI Render Function Source: https://scripting.flarial.xyz/api/gui/gui Renders a movable rectangle with text inside. It accepts the text content and an optional unique index for identification. The default index is 0. ```APIDOC gui.render(text, index) Draws a movable rectangle. Parameters: text: string: The text inside the rectangle. index: number|nil: The unique index, default is 0. ``` -------------------------------- ### Script Execution and Lifecycle Source: https://scripting.flarial.xyz/api/script Defines the core execution function and lifecycle event handlers for script modules. ```APIDOC execute(args: string[]|nil) Called when the command is executed. Parameters: args: The arguments passed to the command. Returns: nil onEnable(): void Called when the module script is enabled via the ClickGUI. Returns: nil onDisable(): void Called when the module script is disabled via the ClickGUI. Returns: nil onLoad(): void Called after a script is compiled and becomes a module or command. Returns: nil ``` -------------------------------- ### ImGui.CollapsingHeader Source: https://scripting.flarial.xyz/api/imgui/imgui Creates a collapsible header widget. It takes a label and optional flags, returning a boolean indicating if the header is open. ```lua function ImGui.CollapsingHeader(label, flags) end ``` -------------------------------- ### Register Command API Source: https://scripting.flarial.xyz/api/misc/globals The registerCommand function allows developers to register custom commands within the scripting environment. It can take a command name and a callback, or a name, description, and callback. Command names must be unique. ```APIDOC registerCommand(name, description_or_callback, callback) Registers a command for use in module scripts. Should be called in the global scope as either: registerCommand(name, callback) or registerCommand(name, description, callback) If the description is omitted, the script’s description will be used. Command names must be unique; registering the same name will overwrite the existing handler. Parameters: name: string: The command name, without spaces. description_or_callback: string|function: Command description or the callback function. callback?: function: The callback to run, required if a description is provided. Returns: nil: ``` -------------------------------- ### Game Events API Documentation Source: https://scripting.flarial.xyz/api/game/events Provides documentation for the 'event' class within the Game Events API. This class is central to handling various game-related events. ```APIDOC event class onEvent(eventName: string, callback: function) eventName: The name of the event to listen for. callback: The function to execute when the event is triggered. Description: Registers a callback function to be executed when a specific game event occurs. Example: event.onEvent("playerJoin", function(player) { print("Player " .. player.name .. " joined the game!"); }); Related: - event.offEvent(eventName: string, callback: function): Unregisters a callback function for a specific event. ``` -------------------------------- ### Game Events API Reference Source: https://scripting.flarial.xyz/api/game/events This section provides a comprehensive reference for game events in the Flarial scripting API. It outlines the available event names, the expected structure of the handler function for each event, and the return type of the event registration. ```APIDOC OpenAIModel: __init__(model_name: str, provider: str = 'openai') model_name: The name of the OpenAI model to use provider: The provider to use (defaults to 'openai') ``` -------------------------------- ### Play Sound Source: https://scripting.flarial.xyz/api/client/audio Plays a sound file. The file path is relative to the Flarial folder. This function does not return any value. ```APIDOC audio.play(file) Plays a sound. Parameters: file: string: The file path relative to the Flarial folder. Returns: nil: ```