Refactor fake itemstack
This commit is contained in:
parent
52bd4bc52e
commit
09dfe9dfff
|
@ -125,9 +125,7 @@ local function get_itemdef_field(itemname, fieldname)
|
|||
return minetest.registered_items[itemname][fieldname]
|
||||
end
|
||||
|
||||
function default.ui.fake_itemstack(x, y, itemstack, name)
|
||||
local name = name or "fake_itemstack"
|
||||
|
||||
function default.ui.fake_itemstack(x, y, itemstack)
|
||||
local itemname = itemstack:get_name()
|
||||
local itemamt = itemstack:get_count()
|
||||
|
||||
|
@ -141,12 +139,10 @@ function default.ui.fake_itemstack(x, y, itemstack, name)
|
|||
|
||||
local result = ""
|
||||
if itemname ~= "" then
|
||||
result = result .. "image_button["..x..","..y..";1,1;blank.png;"
|
||||
..name..";;false;false;blank.png]"
|
||||
result = result .. "item_image["..x..","..y..";1,1;"
|
||||
..minetest.formspec_escape(itemname .. " " .. itemamt).."]"
|
||||
|
||||
result = result .. "tooltip["..name..";"..minetest.formspec_escape(itemdesc).."]"
|
||||
result = result .. "tooltip["..x..","..y..";1,1;"..minetest.formspec_escape(itemdesc).."]"
|
||||
end
|
||||
|
||||
return result
|
||||
|
@ -210,7 +206,7 @@ function default.ui.fake_itemstack_any(x, y, itemstack, name)
|
|||
local group = string.match(itemstack:get_name(), "group:(.*)")
|
||||
|
||||
if group == nil then
|
||||
return default.ui.fake_itemstack(x, y, itemstack, name)
|
||||
return default.ui.fake_itemstack(x, y, itemstack)
|
||||
else
|
||||
return default.ui.item_group(x, y, group, itemstack:get_count(), name)
|
||||
end
|
||||
|
|
|
@ -190,9 +190,9 @@ function gold.trade(trade, trade_type, player)
|
|||
local form = default.ui.get_page("gold_trading_book")
|
||||
form = form .. "label[0.25,0.25;"..minetest.formspec_escape(trade_name).."]"
|
||||
|
||||
form = form .. default.ui.fake_itemstack(1.25, 1.25, trade_wanted1, "trade_wanted1")
|
||||
form = form .. default.ui.fake_itemstack(1.25, 2.25, trade_wanted2, "trade_wanted2")
|
||||
form = form .. default.ui.fake_itemstack(3.75, 1.25, ItemStack(trade[3]), "trade_result")
|
||||
form = form .. default.ui.fake_itemstack(1.25, 1.25, trade_wanted1)
|
||||
form = form .. default.ui.fake_itemstack(1.25, 2.25, trade_wanted2)
|
||||
form = form .. default.ui.fake_itemstack(3.75, 1.25, ItemStack(trade[3]))
|
||||
|
||||
minetest.show_formspec(name, "gold:trading_book", form)
|
||||
|
||||
|
|
Loading…
Reference in New Issue