aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/shapedinventory/cl_shaped.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/inventorysystem/shapedinventory/cl_shaped.lua')
-rw-r--r--gamemode/inventorysystem/shapedinventory/cl_shaped.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/gamemode/inventorysystem/shapedinventory/cl_shaped.lua b/gamemode/inventorysystem/shapedinventory/cl_shaped.lua
index 051f0bc..746a37a 100644
--- a/gamemode/inventorysystem/shapedinventory/cl_shaped.lua
+++ b/gamemode/inventorysystem/shapedinventory/cl_shaped.lua
@@ -18,8 +18,8 @@ end
--[[
-local function calcposition(dimx,dimy,x,y)
- return (y * dimx) + x
+local function calcposition(width,height,x,y)
+ return (y * width) + x
end
]]
@@ -49,7 +49,7 @@ local function drawitemat(self,x,y,item)
print("Drawing item at ",x,y)
local tp = self.gridpanels[x][y]
if tp == nil then
- error("Unable to continue")
+ error("Unable to continue, could not find item at (" .. x .. "," .. y .. ")")
end
tp:Droppable("item")
runonshape(self,item.Shape,x,y,function(panel)
@@ -100,7 +100,7 @@ inv.DrawOnDPanel = function(self,panel)
local grid = vgui.Create( "DGrid", DScrollPanel )
grid:SetPos(0, 0)
- grid:SetCols(self.dimx)
+ grid:SetCols(self.width)
grid:SetColWide(iconsize)
grid:SetRowHeight(iconsize)
self.grid = grid
@@ -108,8 +108,8 @@ inv.DrawOnDPanel = function(self,panel)
self.gridpanels = {}
--Create the full grid of dpanels
- for x = 1, self.dimx do
- for y = 1, self.dimy do
+ for x = 1, self.width do
+ for y = 1, self.height do
local dp = vgui.Create("DModelPanel")
function dp:LayoutEntity( Entity ) return end -- disables default rotation
dp:SetSize(iconsize,iconsize)
@@ -131,8 +131,8 @@ inv.DrawOnDPanel = function(self,panel)
--Go through the items, and set the dpanels appropriately.
for k,v in pairs(self.tracker) do
if type(v) == "table" then
- local px = k % self.dimx
- local py = math.floor(k / self.dimy)
+ local px = k % self.width
+ local py = math.ceil(k / self.height)
drawitemat(self,px,py,v)
end
end