forked from VoxeLibre/VoxeLibre
Dropper + Dispenser inventory
This commit is contained in:
parent
1065eb4d8c
commit
37176976b6
|
@ -8,23 +8,36 @@ All node definitions share a lot of code, so this is the reason why there
|
||||||
are so many weird tables below.
|
are so many weird tables below.
|
||||||
]]
|
]]
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
local C = minetest.colorize
|
||||||
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
-- For after_place_node
|
local dispenser_formspec = table.concat({
|
||||||
|
"formspec_version[4]",
|
||||||
|
"size[11.75,10.425]",
|
||||||
|
|
||||||
|
"label[4.125,0.375;" .. F(C(mcl_formspec.label_color, S("Dispenser"))) .. "]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(4.125, 0.75, 3, 3),
|
||||||
|
"list[context;main;4.125,0.75;3,3;]",
|
||||||
|
|
||||||
|
"label[0.375,4.7;" .. F(C(mcl_formspec.label_color, S("Inventory"))) .. "]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
|
||||||
|
"list[current_player;main;0.375,5.1;9,3;9]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
|
||||||
|
"list[current_player;main;0.375,9.05;9,1;]",
|
||||||
|
|
||||||
|
"listring[context;main]",
|
||||||
|
"listring[current_player;main]",
|
||||||
|
})
|
||||||
|
|
||||||
|
---For after_place_node
|
||||||
|
---@param pos Vector
|
||||||
local function setup_dispenser(pos)
|
local function setup_dispenser(pos)
|
||||||
-- Set formspec and inventory
|
-- Set formspec and inventory
|
||||||
local form = "size[9,8.75]"..
|
|
||||||
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
|
|
||||||
"list[current_player;main;0,4.5;9,3;9]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
|
|
||||||
"list[current_player;main;0,7.74;9,1;]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
|
|
||||||
"label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dispenser"))).."]"..
|
|
||||||
"list[context;main;3,0.5;3,3;]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(3,0.5,3,3)..
|
|
||||||
"listring[context;main]"..
|
|
||||||
"listring[current_player;main]"
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", form)
|
meta:set_string("formspec", dispenser_formspec)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 9)
|
inv:set_size("main", 9)
|
||||||
end
|
end
|
||||||
|
@ -145,7 +158,8 @@ local dispenserdef = {
|
||||||
if igroups.armor then
|
if igroups.armor then
|
||||||
local droppos_below = { x = droppos.x, y = droppos.y - 1, z = droppos.z }
|
local droppos_below = { x = droppos.x, y = droppos.y - 1, z = droppos.z }
|
||||||
|
|
||||||
for _, objs in ipairs({minetest.get_objects_inside_radius(droppos, 1), minetest.get_objects_inside_radius(droppos_below, 1)}) do
|
for _, objs in ipairs({ minetest.get_objects_inside_radius(droppos, 1),
|
||||||
|
minetest.get_objects_inside_radius(droppos_below, 1) }) do
|
||||||
for _, obj in ipairs(objs) do
|
for _, obj in ipairs(objs) do
|
||||||
stack = mcl_armor.equip(stack, obj)
|
stack = mcl_armor.equip(stack, obj)
|
||||||
if stack:is_empty() then
|
if stack:is_empty() then
|
||||||
|
@ -301,7 +315,8 @@ local horizontal_def = table.copy(dispenserdef)
|
||||||
horizontal_def.description = S("Dispenser")
|
horizontal_def.description = S("Dispenser")
|
||||||
horizontal_def._tt_help = S("9 inventory slots") .. "\n" .. S("Launches item when powered by redstone power")
|
horizontal_def._tt_help = S("9 inventory slots") .. "\n" .. S("Launches item when powered by redstone power")
|
||||||
horizontal_def._doc_items_longdesc = S("A dispenser is a block which acts as a redstone component which, when powered with redstone power, dispenses an item. It has a container with 9 inventory slots.")
|
horizontal_def._doc_items_longdesc = S("A dispenser is a block which acts as a redstone component which, when powered with redstone power, dispenses an item. It has a container with 9 inventory slots.")
|
||||||
horizontal_def._doc_items_usagehelp = S("Place the dispenser in one of 6 possible directions. The “hole” is where items will fly out of the dispenser. Use the dispenser to access its inventory. Insert the items you wish to dispense. Supply the dispenser with redstone energy once to dispense a random item.").."\n\n"..
|
horizontal_def._doc_items_usagehelp = S("Place the dispenser in one of 6 possible directions. The “hole” is where items will fly out of the dispenser. Use the dispenser to access its inventory. Insert the items you wish to dispense. Supply the dispenser with redstone energy once to dispense a random item.")
|
||||||
|
.. "\n\n" ..
|
||||||
|
|
||||||
S("The dispenser will do different things, depending on the dispensed item:") .. "\n\n" ..
|
S("The dispenser will do different things, depending on the dispensed item:") .. "\n\n" ..
|
||||||
|
|
||||||
|
|
|
@ -9,23 +9,36 @@ are so many weird tables below.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
local C = minetest.colorize
|
||||||
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
-- For after_place_node
|
local dropper_formspec = table.concat({
|
||||||
|
"formspec_version[4]",
|
||||||
|
"size[11.75,10.425]",
|
||||||
|
|
||||||
|
"label[4.125,0.375;" .. F(C(mcl_formspec.label_color, S("Dropper"))) .. "]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(4.125, 0.75, 3, 3),
|
||||||
|
"list[context;main;4.125,0.75;3,3;]",
|
||||||
|
|
||||||
|
"label[0.375,4.7;" .. F(C(mcl_formspec.label_color, S("Inventory"))) .. "]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
|
||||||
|
"list[current_player;main;0.375,5.1;9,3;9]",
|
||||||
|
|
||||||
|
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
|
||||||
|
"list[current_player;main;0.375,9.05;9,1;]",
|
||||||
|
|
||||||
|
"listring[context;main]",
|
||||||
|
"listring[current_player;main]",
|
||||||
|
})
|
||||||
|
|
||||||
|
---For after_place_node
|
||||||
|
---@param pos Vector
|
||||||
local function setup_dropper(pos)
|
local function setup_dropper(pos)
|
||||||
-- Set formspec and inventory
|
-- Set formspec and inventory
|
||||||
local form = "size[9,8.75]"..
|
|
||||||
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
|
|
||||||
"list[current_player;main;0,4.5;9,3;9]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
|
|
||||||
"list[current_player;main;0,7.74;9,1;]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
|
|
||||||
"label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dropper"))).."]"..
|
|
||||||
"list[context;main;3,0.5;3,3;]"..
|
|
||||||
mcl_formspec.get_itemslot_bg(3,0.5,3,3)..
|
|
||||||
"listring[context;main]"..
|
|
||||||
"listring[current_player;main]"
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", form)
|
meta:set_string("formspec", dropper_formspec)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 9)
|
inv:set_size("main", 9)
|
||||||
end
|
end
|
||||||
|
@ -166,6 +179,7 @@ function horizontal_def.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||||
setup_dropper(pos)
|
setup_dropper(pos)
|
||||||
orientate_dropper(pos, placer)
|
orientate_dropper(pos, placer)
|
||||||
end
|
end
|
||||||
|
|
||||||
horizontal_def.tiles = {
|
horizontal_def.tiles = {
|
||||||
"default_furnace_top.png", "default_furnace_bottom.png",
|
"default_furnace_top.png", "default_furnace_bottom.png",
|
||||||
"default_furnace_side.png", "default_furnace_side.png",
|
"default_furnace_side.png", "default_furnace_side.png",
|
||||||
|
|
Loading…
Reference in New Issue