1+ name = " Armor Display"
2+ description = " Displays armor items beside the hotbar"
3+
4+ showDurability = client .settings .addNamelessBool (" Show Durability" , true )
5+ showSlot = client .settings .addNamelessBool (" Show Slot Icon" , true )
6+
7+ function getHotbarBounds ()
8+
9+ local screenSafeArea = gui .screenSafe ()
10+
11+ local scaledWidth = gui .width ()
12+ local scaledHeight = gui .height ()
13+
14+ local hotbarBaseWidth = 183
15+ local hotbarBaseHeight = 24
16+
17+ local hotbarScaledX = (scaledWidth - hotbarBaseWidth ) / 2
18+
19+ local safeAreaScale = (1 - screenSafeArea )
20+ local scaledSafeAreaOffsetY = scaledHeight * safeAreaScale
21+ local hotbarScaledY = scaledHeight - hotbarBaseHeight - (scaledSafeAreaOffsetY * 0.5 )
22+
23+ local hotbarX = hotbarScaledX
24+ local hotbarY = hotbarScaledY - (18 )
25+ local hotbarWidth = hotbarBaseWidth
26+ local hotbarHeight = (hotbarBaseHeight - 1 ) + (18 )
27+ return hotbarX , hotbarY , hotbarWidth , hotbarHeight
28+
29+ end
30+
31+
32+ function getHotbarPosition ()
33+
34+ screenWidth = gui .width ()
35+ screenHeight = gui .height ()
36+
37+ local hx , hy , hw , hh = getHotbarBounds ()
38+ local hotbarCenterX = screenWidth / 2
39+ local hotbarY = (hy + hh ) - 22
40+
41+
42+ return hotbarCenterX , hotbarY
43+ end
44+ function slot (x , y , item , isLeft , isRight )
45+ if isLeft == nil then isLeft = false end
46+ if isRight == nil then isRight = false end
47+ local hotbarX , hotbarY = getHotbarPosition ()
48+ local slotX , slotY = hotbarX + x , hotbarY - y
49+ if showSlot .value then
50+ gfx .texture (slotX , slotY , 20 , 22 ," textures/ui/hotbar_1" )
51+ if isLeft then gfx .texture (slotX - 1 , slotY , 1 , 22 , " textures/ui/hotbar_end_cap" ) end
52+ if isRight then gfx .texture (slotX + 20 , slotY , 1 , 22 , " textures/ui/hotbar_end_cap" ) end
53+ end
54+ local itemX , itemY = slotX + 1.8 , slotY + 3
55+ if item then gfx .item (itemX , itemY , item .location , 1 , showDurability .value ) end
56+ end
57+
58+
59+
60+ function render (dt )
61+ local armor = player .inventory ().armor ()
62+ if not armor then return end
63+
64+ slot (- 133 , 0.6 , armor .helmet , true )
65+
66+ slot (- 113 , 0.6 , armor .chestplate , false , true )
67+
68+ slot (93 , 0.6 , armor .leggings , true )
69+
70+ slot (113 , 0.6 , armor .boots , false , true )
71+ end
0 commit comments