Skip to content

Commit 0dbbd5c

Browse files
committed
Add logic for toggling inventory
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
1 parent 1610521 commit 0dbbd5c

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

src/Api/getEnabled.luau

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--!strict
2+
3+
local Players = game:GetService("Players")
4+
local RunService = game:GetService("RunService")
5+
6+
local player = Players.LocalPlayer
7+
local playerGui = player:WaitForChild("PlayerGui")
8+
local screenGui = playerGui:WaitForChild("SatchelGui")
9+
10+
local function getEnabled()
11+
assert(RunService:IsClient(), "getEnabled can only be called on the client")
12+
13+
return screenGui.Enabled
14+
end
15+
16+
return getEnabled

src/Api/getTopbarIcon.luau

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ local RunService = game:GetService("RunService")
44

55
local TopbarPlus = require(script.Parent.Parent.Parent.topbarplus)
66

7-
local function getTopbarIcon(): TopbarPlus.Icon
7+
local function getTopbarIcon(): TopbarPlus.Icon?
88
assert(RunService:IsClient(), "getTopbarIcon can only be called on the client")
9-
print("Not implemented")
9+
10+
for _, icon in TopbarPlus.getIcons() do
11+
if icon.captionText == "Inventory" then
12+
return icon
13+
end
14+
end
15+
1016
return nil
1117
end
1218

src/Api/setEnabled.luau

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
local Players = game:GetService("Players")
44
local RunService = game:GetService("RunService")
55

6+
local getTopbarIcon = require(script.Parent.getTopbarIcon)
7+
68
local player = Players.LocalPlayer
79
local playerGui = player:WaitForChild("PlayerGui")
810
local screenGui = playerGui:WaitForChild("SatchelGui")
@@ -12,7 +14,10 @@ local function setEnabled(isEnabled: boolean)
1214

1315
screenGui.Enabled = isEnabled
1416

15-
-- TODO: Disable topbar icon
17+
local icon = getTopbarIcon()
18+
if icon then
19+
icon:setEnabled(isEnabled)
20+
end
1621
end
1722

1823
return setEnabled

src/init.luau

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local bindableEvents = script.BindableEvents
44

55
return {
66
-- Functions
7+
getEnabled = require(script.Api.getEnabled),
78
setEnabled = require(script.Api.setEnabled),
89
getTopbarIcon = require(script.Api.getTopbarIcon),
910
openInventory = require(script.Api.openInventory),

0 commit comments

Comments
 (0)