Skip to content

Conversation

@ryanlua
Copy link
Owner

@ryanlua ryanlua commented Dec 5, 2025

This pull request updates the documentation and refactors the TopbarIcon.client.luau script to improve clarity and functionality for the CoreGui backpack inventory toggle and state handling. The main changes include clearer sample code in the API docs and a more robust event-driven approach in the icon script.

Documentation improvements:

  • Added a descriptive code sample showing how to toggle the inventory using OpenClose() from a button's Activated event.
  • Added a sample demonstrating how to listen for the StateChanged event to detect when the inventory is opened or closed.

Code refactoring and event handling:

  • Renamed image asset variables in TopbarIcon.client.luau to uppercase for clarity and consistency.
  • Replaced manual input handling with a connection to BackpackScript.StateChanged.Event to update the icon's selected state based on inventory open/close events.
  • Updated the icon toggle logic to only call BackpackScript.OpenClose() when the toggle is initiated by the user, improving separation of concerns and preventing redundant toggles.

Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
Removed unused UserInputService import.

Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
@ryanlua ryanlua self-assigned this Dec 5, 2025
Copilot AI review requested due to automatic review settings December 5, 2025 23:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the topbar icon logic to use an event-driven approach for synchronizing the icon's visual state with the inventory's open/close state, and improves the API documentation with practical code examples.

Key changes:

  • Replaced manual input handling with BackpackScript.StateChanged event subscription to automatically sync icon state with inventory visibility
  • Modified icon toggle handler to only call BackpackScript.OpenClose() when triggered by user interaction (via fromSource parameter), preventing redundant toggles
  • Added descriptive code samples in the documentation demonstrating usage of OpenClose() and StateChanged APIs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/TopbarIcon.client.luau Refactored event handling to use BackpackScript.StateChanged for icon state synchronization and renamed image constants to uppercase
docs/api-reference.md Added introductory text and code samples demonstrating OpenClose() and StateChanged usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ryanlua ryanlua added this to the v1.1.0 milestone Dec 5, 2025
@ryanlua ryanlua added bug Something isn't working documentation Improvements or additions to documentation labels Dec 5, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
@ryanlua ryanlua merged commit 0f972e6 into main Dec 5, 2025
2 checks passed
@ryanlua ryanlua deleted the icon-deselect branch December 5, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant