Skip to content

Commit

Permalink
Fix trader bug
Browse files Browse the repository at this point in the history
  • Loading branch information
camirmas committed Aug 29, 2023
1 parent c77db12 commit 409b90a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions projects/jam.p8
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ function create_trade_ui(trade_item, qty)
end,

on_O = function(self)
if self.selected == 1 and self.qty > 0 then
if self.selected == 1 and self.qty > 0 and self:tradeable() then
self:trade()
self.qty -= 1
else
Expand Down Expand Up @@ -1444,10 +1444,9 @@ function create_trade_ui(trade_item, qty)
local cx = r[1] + 4
local cy = r[2] + 4

local name = self.item.disp_name or self.item.name
local p_qty = player.backpack.items[self.item.name].quantity
draw_item(self.item, cx, cy)
print(name .. " X " .. self.qty, cx + 20, cy + 2, 0)
print(self.item.disp_name .. " X " .. self.qty, cx + 20, cy + 2, 0)

if (self.qty == 0) return

Expand All @@ -1463,23 +1462,23 @@ function create_trade_ui(trade_item, qty)
local p_qty = player.backpack.junk[name].quantity
local j = junk[name]
draw_junk(j, cx, cy)
print(j.name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 2, 0)
print(j.disp_name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 2, 0)
cy += 14
end

for name, qty in pairs(self.item.fish) do
local p_qty = player.backpack.fish[name].quantity
local f = fish[name]
draw_fish(f, cx, cy)
print(f.name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 4, 0)
print(f.disp_name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 4, 0)
cy += 18
end

for name, qty in pairs(self.item.items) do
local p_qty = player.backpack.items[name].quantity
local i = items[name]
draw_item(i, cx, cy)
print(i.name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 4, 0)
print(i.disp_name .. " X " .. p_qty .. "/" .. qty, cx + 20, cy + 4, 0)
cy += 18
end

Expand Down

0 comments on commit 409b90a

Please sign in to comment.