aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/prayers
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/inventorysystem/prayers')
-rw-r--r--gamemode/inventorysystem/prayers/cl_prayers.lua20
-rw-r--r--gamemode/inventorysystem/prayers/sh_prayers.lua9
2 files changed, 18 insertions, 11 deletions
diff --git a/gamemode/inventorysystem/prayers/cl_prayers.lua b/gamemode/inventorysystem/prayers/cl_prayers.lua
index afea1cc..e28db63 100644
--- a/gamemode/inventorysystem/prayers/cl_prayers.lua
+++ b/gamemode/inventorysystem/prayers/cl_prayers.lua
@@ -8,7 +8,7 @@ function pray:DrawOnDPanel(panel)
--Active grid
local agrid = vgui.Create("DGrid",panel)
agrid:SetCols(4)
- local w = ((ScrW()/4) - 10) / 4
+ local w = ((ScrW() / 4) - 10) / 4
agrid:SetHeight(w)
agrid:SetColWide(w)
agrid:SetRowHeight(w)
@@ -17,14 +17,19 @@ function pray:DrawOnDPanel(panel)
rec:SetText("F"..i)
rec:SetSize(w,w)
rec.DoClick = function(s)
- local ap = self.activeprayers[i]
+ local ap = pray.activeprayers[i]
explain:SetText(ap ~= nil and ap.Description or "Select a prayer")
end
rec:Receiver("prayer",function(s,tbl,dropped,mi,x,y)
if not dropped then return end
- self.activeprayers[i] = tbl.item
- if tbl.item.DoOnPanel then
- tbl.item.DoOnPanel(s)
+ pray.activeprayers[i] = tbl[1].item
+ if tbl[1].item == nil then
+ print("Failed to get item, tbl was")
+ PrintTable(tbl)
+ error("Failed to get item")
+ end
+ if tbl[1].item.DoOnPanel then
+ tbl[1].item:DoOnPanel(rec)
end
end,{})
agrid:AddItem(rec)
@@ -64,6 +69,7 @@ function pray:DrawOnDPanel(panel)
local observer = {}
observer.Put = function(obs,pos,item)
print("Prayer observer got request to put")
+ debug.Trace()
drawprayer(item)
end
observer.Remove = function(obs,pos,item)
@@ -79,12 +85,12 @@ local prayerhooks = {
["gm_showspare1"] = 3,
["gm_showspare2"] = 4
}
-hook.Add("PlayerBindPress", function( ply, bind, pressed )
+hook.Add("PlayerBindPress", "pray_hook", function( ply, bind, pressed )
local phn = prayerhooks[bind]
if phn == nil then return end
local pap = pray.activeprayers[phn]
if pap == nil then return end
- pap:pray()
+ pap:Pray()
end)
return pray
diff --git a/gamemode/inventorysystem/prayers/sh_prayers.lua b/gamemode/inventorysystem/prayers/sh_prayers.lua
index e1e7347..9d8ff3b 100644
--- a/gamemode/inventorysystem/prayers/sh_prayers.lua
+++ b/gamemode/inventorysystem/prayers/sh_prayers.lua
@@ -14,7 +14,7 @@ end
inv.Name = "Prayers"
inv.track = {}
function inv:FindPlaceFor(item)
- if item.isprayer then
+ if item.Pray ~= nil then
return {#self.track}
end
return nil
@@ -54,14 +54,15 @@ function inv:Serialize()
end
function inv:DeSerialize(str)
- local cpy = table.Copy(self)
+ self.track = {}
local tbl = util.JSONToTable(str)
+ tbl = tbl or {}
local i = 1
for k,v in pairs(tbl) do
local this_prayer = itm.GetItemByName(k):DeSerialize(v)
- cpy:Put({i},this_prayer)
+ self:Put({i},this_prayer)
end
- return cpy
+ return self
end