Ledger System
Note: The code provided cannot be used as an "Export." Therefore, you can access all the necessary examples and code in the client folder, specifically in the ledger.lua file.
Last updated
Note: The code provided cannot be used as an "Export." Therefore, you can access all the necessary examples and code in the client folder, specifically in the ledger.lua file.
Last updated
This system manages the display of a ledger in an interactive way within a game. The code allows adding pages, handling page items, and responding to user interactions such as selecting or hovering over items.
client
folder, specifically in the ledger.lua
file.pageitem
The pageitem
table represents a single item on a page in the ledger. This item includes properties such as visibility, title, notes, price, and event handlers for user interaction (select and hover events).
Code Example:
Description:
visible: Determines whether the item is visible on the page.
title: The title of the page item.
notes: Notes or additional information related to the item.
sketchTexture: The texture used to display the sketch image on the page.
crossedOut: Boolean to indicate if the item should appear as crossed out.
price: Contains details about the item's price, including hover status and whether it's highlighted or crossed out.
hovered: Indicates if the price is currently hovered.
price: The actual price of the item, in this case, $241
.
crossedOutTexture: The texture used when the item is crossed out.
highlighted: Indicates if the price is highlighted.
Event Handlers:
onSelect: Function triggered when the item is selected by the user. It prints the title and notes, and calls the crossed
function.
onHovered: Function triggered when the item is hovered by the user. It prints the title and notes.
contribution
The contribution
table represents a contribution entry in the ledger. It includes the contributor’s name, visibility, price, and description.
Code Example:
Description:
name: The name of the contributor (in this case, Wyatt Earp).
visible: Determines if the contribution entry is visible.
price: The amount of the contribution ($81).
description: A description of the contribution (Sheriff’s fee).
fullPageUpgrade
This table represents an upgrade that can be displayed on a full page. It includes details such as visibility, title, crossed-out status, notes, and price information.
Code Example:
Description:
visible: Determines if the upgrade is visible.
title: The title of the upgrade.
crossedOut: Indicates whether the upgrade is crossed out.
crossedOutTexture: The texture to use when the upgrade is crossed out.
notes: Additional notes about the upgrade.
price: Contains price information for the upgrade.
hovered: Indicates if the price is hovered.
price: The cost of the upgrade.
crossedOutTexture: The texture used if the price is crossed out.
highlighted: Whether the price is highlighted.
Event Handlers:
onSelect: Prints the selected upgrade's title and notes, and calls the crossed
function.
onHovered: Prints the hovered upgrade's title and notes.
fullPageReStock
The fullPageReStock
table defines an item in the restock section of a full page. It handles whether the item is crossed out, hovered, and its price.
Code Example:
Description:
index: The index of the restock item.
crossedOut: Whether the item is crossed out.
hovered: Whether the item is hovered.
price: The price of the restock item.
crossedOutTexture: The texture used if the item is crossed out.
highlighted: Whether the price is highlighted.
Event Handlers:
onSelect: Prints the selected restock item's index and price, and calls the crossed
function.
onHovered: Prints the hovered restock item's index and price.
The ledger
function allows the creation of ledger pages and adding different types of pages to it. Pages can be of type PageItems
, ContPage
, or FullPage
, each with its own structure.
Code Example:
The script also registers event handlers for various actions such as selecting or hovering over ledger items, as well as entering or exiting a volume around a ledger. Below are the event handlers implemented in the code:
Event Example:
Descriptions:
qadr_ui:ledger_selectedItem: Triggered when an item in the ledger is selected. The data
returned contains information about the selected item.
qadr_ui:ledger_hovered: Triggered when an item in the ledger is hovered over. The data
returned contains information about the hovered item.
qadr_ui:ledger_in_volume: Triggered when the player enters a specific volume around the ledger. The data
returned contains information about the volume, and the player can start interacting with the ledger. For example, you might display a prompt to the player when they enter the volume.
qadr_ui:ledger_out_volume: Triggered when the player exits a volume around the ledger. The data
returned contains information about the volume, and you can use this event to remove any prompts or interaction options when the player leaves the area.