1
0
mirror of https://github.com/SmallJoker/exchange_shop.git synced 2025-07-17 23:50:22 +02:00

Make luacheck happy and fix bug

This commit is contained in:
luk3yx
2022-11-08 21:48:10 +13:00
parent 68ced48485
commit 186e758873
2 changed files with 8 additions and 6 deletions

View File

@ -8,6 +8,8 @@ read_globals = {
"AreaStore", "AreaStore",
"default", "default",
"mesecon", "mesecon",
"utf8",
"flow",
} }
globals = { globals = {

View File

@ -77,7 +77,9 @@ local function get_exchange_shop_formspec(mode, pos, meta)
for y2 = 1, h do for y2 = 1, h do
for x2 = 1, w do for x2 = 1, w do
i = i + 1 i = i + 1
fs[#fs + 1] = ("image_button[%s,%s;1.2,1.2;;%s_%s;;false;false]"):format(x + x2 - 1.1, y + y2 - 1.1, list, i) fs[#fs + 1] = ("image_button[%s,%s;1.2,1.2;;%s_%s;;false;false]"):format(
x + x2 - 1.1, y + y2 - 1.1, list, i
)
end end
end end
return tconcat(fs) return tconcat(fs)
@ -221,7 +223,7 @@ local item_picker = flow.make_gui(function(player, ctx)
row[#row + 1] = gui.ItemImageButton{ row[#row + 1] = gui.ItemImageButton{
w = 1, h = 1, w = 1, h = 1,
item_name = item, item_name = item,
on_event = function(p, c) on_event = function(_, c)
if c.item ~= item or c.form.amount ~= "1" then if c.item ~= item or c.form.amount ~= "1" then
c.item = item c.item = item
c.desc = description or item c.desc = description or item
@ -238,8 +240,6 @@ local item_picker = flow.make_gui(function(player, ctx)
rows[#rows + 1] = gui.Label{label = S("No items found.")} rows[#rows + 1] = gui.Label{label = S("No items found.")}
end end
local item_preview
return gui.VBox{ return gui.VBox{
gui.HBox{ gui.HBox{
gui.Style{selectors = {"back"}, props = {border = false}}, gui.Style{selectors = {"back"}, props = {border = false}},
@ -298,7 +298,7 @@ local item_picker = flow.make_gui(function(player, ctx)
gui.Button{ gui.Button{
label = S("Clear"), label = S("Clear"),
w = 3.5, w = 3.5,
on_event = function(p, c) on_event = function(_, c)
c.item = "" c.item = ""
c.form.amount = "0" c.form.amount = "0"
return true return true
@ -404,7 +404,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
for _, stack in ipairs(shop_inv:get_list(listname)) do for _, stack in ipairs(shop_inv:get_list(listname)) do
local leftover = pinv:add_item("main", stack) local leftover = pinv:add_item("main", stack)
if not leftover:is_empty() then if not leftover:is_empty() then
minetest.add_item(sender:get_pos(), remaining_stack) minetest.add_item(sender:get_pos(), leftover)
end end
end end
end end