aboutsummaryrefslogtreecommitdiff
path: root/gamemode/client/cl_inventory.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/client/cl_inventory.lua')
-rw-r--r--gamemode/client/cl_inventory.lua21
1 files changed, 12 insertions, 9 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index 0e14d50..b1f5728 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -9,6 +9,7 @@
4 - Quests
]]
local qinv = nrequire("cl_qinventory.lua")
+local state = nrequire("cl_state.lua") --Holds weather or not player is in inventory
--local qpray = nrequire("cl_qprayers.lua")
print("Hello from cl_inventory.lua")
@@ -25,9 +26,6 @@ end)
local lastpanel = lastpanel or 1
---Wether the player is in the inventory or not
-local plyisininventory = false
-
local qframe = nil --The master frame
local qtabs = {} --The tabs
@@ -53,7 +51,12 @@ local function BuildInventory()
qframe:SetDraggable(true)
qframe:MakePopup()
qframe.OnClose = function(self)
- plyisininventory = false
+ state.invopen = false
+ self:Hide()
+ return
+ end
+ qframe.Remove = function(self)
+ state.invopen = false
self:Hide()
return
end
@@ -75,14 +78,14 @@ local function ShowInventory()
print("qframe is ", qframe)
if not qframe then BuildInventory()
else qframe:Show() end
- plyisininventory = true
+ state.invopen = true
end
hook.Add("OnSpawnMenuOpen","ArteryOpenInventory",ShowInventory)
hook.Add("OnSpawnMenuClose","ArteryCloseInventory",function()
- plyisininventory = false
+ state.invopen = false
qframe:Hide()
if (not sheet) or (not sheet:GetActiveTab()) or (not sheet:GetActiveTab():GetPanel()) then return end
lastpanel = sheet:GetActiveTab():GetPanel().sheetnum
@@ -106,7 +109,7 @@ hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz)
local view = {}
--view.origin = LocalPlayer():GetBonePosition(bone) + LocalPlayer():GetUp() * 2
view.origin = pos
- if plyisininventory then
+ if state.invopen then
local trot = math.rad(CurTime() * rotatespeed)
local xoff = viewdistance * math.sin(trot)
local yoff = viewdistance * math.cos(trot)
@@ -116,12 +119,12 @@ hook.Add("CalcView","ArteryInventoryView",function(ply,pos,ang,fov,nearz,farz)
end
view.angles = ang
view.fov = fov
- if not plyisininventory then
+ if not state.invopen then
LocalPlayer():ManipulateBoneScale(bone,Vector(0,0,0))
else
LocalPlayer():ManipulateBoneScale(bone,previousheadscale)
end
- view.drawviewer = plyisininventory
+ view.drawviewer = state.invopen
return view
end)