Fancier Mailbox formspec
This commit is contained in:
parent
2cbfd8ff0b
commit
afdbfc316f
@ -50,15 +50,11 @@ function enchanting.fields(pos, _, fields, _)
|
||||
|
||||
if mese > 0 and fields[ench] then
|
||||
local enchanted_tool = modname..":enchanted_"..toolname.."_"..ench
|
||||
local tdef = minetest.registered_tools[enchanted_tool]
|
||||
|
||||
if tdef then
|
||||
toolstack:replace(enchanted_tool)
|
||||
toolstack:add_wear(toolwear)
|
||||
mesestack:take_item()
|
||||
inv:set_stack("mese", 1, mesestack)
|
||||
inv:set_stack("tool", 1, toolstack)
|
||||
end
|
||||
toolstack:replace(enchanted_tool)
|
||||
toolstack:add_wear(toolwear)
|
||||
mesestack:take_item()
|
||||
inv:set_stack("mese", 1, mesestack)
|
||||
inv:set_stack("tool", 1, toolstack)
|
||||
end
|
||||
end
|
||||
|
||||
|
48
mailbox.lua
48
mailbox.lua
@ -50,7 +50,7 @@ xdecor.register("mailbox", {
|
||||
inv:remove_item("drop", stack)
|
||||
inv:add_item("mailbox", stack)
|
||||
|
||||
for i = 4, 2, -1 do
|
||||
for i = 7, 2, -1 do
|
||||
meta:set_string("giver"..i, meta:get_string("giver"..(i-1)))
|
||||
meta:set_string("stack"..i, meta:get_string("stack"..(i-1)))
|
||||
end
|
||||
@ -68,23 +68,59 @@ xdecor.register("mailbox", {
|
||||
end
|
||||
})
|
||||
|
||||
local function img_col(stack)
|
||||
if not stack then return "" end
|
||||
if stack.type == "node" then
|
||||
if stack.inventory_image ~= "" then
|
||||
return stack.inventory_image
|
||||
else
|
||||
return stack.tiles[1]
|
||||
end
|
||||
elseif stack.type == "tool" or stack.type == "craft" then
|
||||
return stack.inventory_image
|
||||
else return "" end
|
||||
end
|
||||
|
||||
function mailbox.formspec(pos, owner, num)
|
||||
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||
local spos = pos.x..","..pos.y..","..pos.z
|
||||
local meta = minetest.get_meta(pos)
|
||||
local giver = ""
|
||||
local def_stack1 = minetest.registered_items[meta:get_string("stack1"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack2 = minetest.registered_items[meta:get_string("stack2"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack3 = minetest.registered_items[meta:get_string("stack3"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack4 = minetest.registered_items[meta:get_string("stack4"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack5 = minetest.registered_items[meta:get_string("stack5"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack6 = minetest.registered_items[meta:get_string("stack6"):match("([%w_]+:[%w_]+)")]
|
||||
local def_stack7 = minetest.registered_items[meta:get_string("stack7"):match("([%w_]+:[%w_]+)")]
|
||||
|
||||
if num == 1 then
|
||||
for i = 1, 4 do
|
||||
for i = 1, 7 do
|
||||
if meta:get_string("giver"..i) ~= "" then
|
||||
giver = giver.."#FFFF00,"..meta:get_string("giver"..i)..",,\t"..meta:get_string("stack"..i)..","
|
||||
giver = giver.."#FFFF00,"..meta:get_string("giver"..i):sub(1, 12)..
|
||||
","..i..",#FFFFFF,x "..meta:get_string("stack"..i):sub(-3):match("%d+")..","
|
||||
end
|
||||
end
|
||||
return "size[11,9]"..xbg..default.get_hotbar_bg(1.5,5.25)..
|
||||
"label[0,0;Mailbox :]label[6,0;Last donators :]box[6,0.72;4.85,3.92;#555555]tablecolumns[color;text]tableoptions[background=#00000000;highlight=#00000000;border=false]table[6,0.77;4.85,4.4;givers;"..giver.."]list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]list[current_player;main;1.5,5.25;8,4;]"
|
||||
|
||||
return "size[9.5,9]"..xbg..default.get_hotbar_bg(0.75,5.25)..
|
||||
"label[0,0;Mailbox :]label[6,0;Last donators :]"..
|
||||
"tablecolumns[color;text;image,"..
|
||||
"1="..img_col(def_stack1)..","..
|
||||
"2="..img_col(def_stack2)..","..
|
||||
"3="..img_col(def_stack3)..","..
|
||||
"4="..img_col(def_stack4)..","..
|
||||
"5="..img_col(def_stack5)..","..
|
||||
"6="..img_col(def_stack6)..","..
|
||||
"7="..img_col(def_stack7)..";color;text]"..
|
||||
"tableoptions[background=#434343;highlight=#00000000;border=true]"..
|
||||
"table[6,0.75;3.3,4;givers;"..giver.."]"..
|
||||
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
|
||||
"list[current_player;main;0.75,5.25;8,4;]"
|
||||
else
|
||||
return "size[8,5]"..xbg..default.get_hotbar_bg(0,1.25)..
|
||||
"label[0.5,0;Send your goods\nto "..owner.." :]list[nodemeta:"..spos..";drop;3.5,0;1,1;]list[current_player;main;0,1.25;8,4;]"
|
||||
"label[0.5,0;Send your goods\nto "..owner.." :]"..
|
||||
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
|
||||
"list[current_player;main;0,1.25;8,4;]"
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user