Add a chest-like visible armor stand, closes #48

This commit is contained in:
stujones11 2016-04-03 20:15:40 +01:00
parent 7408ebcd81
commit fb29ce9150
11 changed files with 579 additions and 0 deletions

@ -0,0 +1,7 @@
[mod] 3d Armor Stand [3d_armor_stand]
=====================================
License Source Code: LGPL v2.1
Lecense Media: CC BY-SA 3.0

21
3d_armor_stand/README.txt Normal file

@ -0,0 +1,21 @@
[mod] 3d Armor Stand [3d_armor_stand]
=====================================
Depends: 3d_armor
Adds a chest-like armor stand for armor storage and display.
Crafting
--------
F = Wooden Fence [default:fence_wood]
S = Steel Ingot [default:steel_ingot]
+---+---+---+
| | F | |
+---+---+---+
| | F | |
+---+---+---+
| S | S | S |
+---+---+---+

@ -0,0 +1,2 @@
3d_armor

158
3d_armor_stand/init.lua Normal file

@ -0,0 +1,158 @@
local armor_stand_formspec = "size[8,7]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
default.get_hotbar_bg(0,3) ..
"list[current_name;armor_head;3,0.5;1,1;]" ..
"list[current_name;armor_torso;4,0.5;1,1;]" ..
"list[current_name;armor_legs;3,1.5;1,1;]" ..
"list[current_name;armor_feet;4,1.5;1,1;]" ..
"image[3,0.5;1,1;3d_armor_stand_head.png]" ..
"image[4,0.5;1,1;3d_armor_stand_torso.png]" ..
"image[3,1.5;1,1;3d_armor_stand_legs.png]" ..
"image[4,1.5;1,1;3d_armor_stand_feet.png]" ..
"list[current_player;main;0,3;8,1;]" ..
"list[current_player;main;0,4.25;8,3;8]"
local elements = {"head", "torso", "legs", "feet"}
local function update_entity(pos)
local object = nil
local node = minetest.get_node(pos)
local objects = minetest.get_objects_inside_radius(pos, 1) or {}
for _, obj in pairs(objects) do
local ent = obj:get_luaentity()
if ent then
if ent.name == "3d_armor_stand:armor_entity" then
-- Remove duplicates
if object then
obj:remove()
else
object = obj
end
end
end
end
if object then
if node.name ~= "3d_armor_stand:armor_stand" then
object:remove()
return
end
else
object = minetest.add_entity(pos, "3d_armor_stand:armor_entity")
end
if object then
local texture = "3d_armor_trans.png"
local textures = {}
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local yaw = 0
if inv then
for _, element in pairs(elements) do
local stack = inv:get_stack("armor_"..element, 1)
if stack:get_count() == 1 then
local item = stack:get_name() or ""
local def = stack:get_definition() or {}
local texture = def.texture or item:gsub("%:", "_")
table.insert(textures, texture..".png")
end
end
end
if #textures > 0 then
texture = table.concat(textures, "^")
end
if node.param2 then
local rot = node.param2 % 4
if rot == 1 then
yaw = 3 * math.pi / 2
elseif rot == 2 then
yaw = math.pi
elseif rot == 3 then
yaw = math.pi / 2
end
end
object:setyaw(yaw)
object:set_properties({textures={texture}})
end
end
minetest.register_node("3d_armor_stand:armor_stand", {
description = "Armor stand",
drawtype = "mesh",
mesh = "3d_armor_stand.obj",
tiles = {"default_wood.png", "default_steel_block.png"},
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.5,-0.5,-0.5, 0.5,1.4,0.5}
},
groups = {choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", armor_stand_formspec)
meta:set_string("infotext", "Armor Stand")
local inv = meta:get_inventory()
for _, element in pairs(elements) do
inv:set_size("armor_"..element, 1)
end
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for _, element in pairs(elements) do
if not inv:is_empty("armor_"..element) then
return false
end
end
return true
end,
after_place_node = function(pos)
minetest.add_entity(pos, "3d_armor_stand:armor_entity")
end,
allow_metadata_inventory_put = function(pos, listname, index, stack)
local def = stack:get_definition() or {}
local groups = def.groups or {}
if groups[listname] then
return 1
end
return 0
end,
allow_metadata_inventory_move = function(pos)
return 0
end,
on_metadata_inventory_put = function(pos)
update_entity(pos)
end,
on_metadata_inventory_take = function(pos)
update_entity(pos)
end,
after_destruct = function(pos)
update_entity(pos)
end,
})
minetest.register_entity("3d_armor_stand:armor_entity", {
physical = true,
visual = "mesh",
mesh = "3d_armor_entity.obj",
visual_size = {x=1, y=1},
collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1},
textures = {"3d_armor_trans.png"},
on_activate = function(self)
local pos = self.object:getpos()
update_entity(pos)
end,
})
minetest.register_craft({
output = "3d_armor_stand:armor_stand",
recipe = {
{"", "default:fence_wood", ""},
{"", "default:fence_wood", ""},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
}
})

@ -0,0 +1,193 @@
# Blender v2.73 (sub 0) OBJ File: '3d_armor_entity_3.blend'
# www.blender.org
mtllib 3d_armor_entity.mtl
o Player_Cube
v 2.200000 9.763893 1.200000
v 2.200000 9.763893 -1.200000
v 2.200000 2.663871 1.200000
v 2.200000 2.663871 -1.200000
v -2.200000 9.763893 -1.200000
v -2.200000 9.763893 1.200000
v -2.200000 2.663871 -1.200000
v -2.200000 2.663871 1.200000
v 2.300000 13.863962 2.300000
v 2.300000 13.863962 -2.300000
v 2.300000 9.263885 2.300000
v 2.300000 9.263885 -2.300000
v -2.300000 13.863962 -2.300000
v -2.300000 13.863962 2.300000
v -2.300000 9.263885 -2.300000
v -2.300000 9.263885 2.300000
v -2.322686 2.473175 -1.300000
v -2.322686 2.473175 1.300000
v -4.713554 2.682348 1.300000
v -4.713554 2.682348 -1.300000
v -1.686446 9.745432 -1.300000
v -1.686446 9.745432 1.300000
v -4.077313 9.954605 1.300000
v -4.077313 9.954605 -1.300000
v 4.077313 9.954605 -1.300000
v 4.077313 9.954605 1.300000
v 1.686446 9.745432 1.300000
v 1.686446 9.745432 -1.300000
v 4.713554 2.682348 -1.300000
v 4.713554 2.682348 1.300000
v 2.322686 2.473175 1.300000
v 2.322686 2.473175 -1.300000
v 0.139099 2.938947 -1.200000
v 0.139099 2.938947 1.200000
v 0.261266 -4.059988 1.200000
v 0.261266 -4.059988 -1.200000
v 2.660901 -4.018101 1.190000
v 2.660901 -4.018101 -1.210000
v 2.538733 2.980834 1.190000
v 2.538733 2.980834 -1.210000
v -0.139099 2.938947 -1.200000
v -0.139099 2.938947 1.200000
v -0.261266 -4.059988 1.200000
v -0.261266 -4.059988 -1.200000
v -2.538734 2.980834 -1.210000
v -2.538734 2.980834 1.190000
v -2.660901 -4.018101 -1.210000
v -2.660901 -4.018101 1.190000
v -2.799999 -4.387500 1.390000
v -2.799999 -4.387500 -1.410000
v -2.800000 -0.812499 1.390000
v -2.800000 -0.812499 -1.410000
v -0.000000 -4.387500 -1.400000
v -0.000000 -4.387500 1.400000
v -0.000000 -0.812499 1.400000
v -0.000000 -0.812499 -1.400000
v 2.800000 -0.812499 -1.410000
v 2.800000 -0.812499 1.390000
v 2.799999 -4.387500 -1.410000
v 2.799999 -4.387500 1.390000
v 0.000000 -4.387500 -1.400000
v 0.000000 -4.387500 1.400000
v 0.000000 -0.812499 1.400000
v 0.000000 -0.812499 -1.400000
v 2.267006 13.830965 2.267006
v 2.267006 13.830965 -2.267006
v 2.267006 9.296881 2.267006
v 2.267006 9.296881 -2.267006
v -2.267006 13.830965 -2.267006
v -2.267006 13.830965 2.267006
v -2.267006 9.296881 -2.267006
v -2.267006 9.296881 2.267006
vt 0.250000 0.375000
vt 0.250000 0.000000
vt 0.312500 0.000000
vt 0.312500 0.375000
vt 0.437500 0.375000
vt 0.437500 0.500000
vt 0.312500 0.500000
vt 0.562500 0.375000
vt 0.562500 0.500000
vt 0.437500 0.000000
vt 0.500000 0.000000
vt 0.500000 0.375000
vt 0.625000 0.000000
vt 0.625000 0.375000
vt 0.500000 0.750000
vt 0.500000 0.500000
vt 0.625000 0.500000
vt 0.625000 0.750000
vt 0.750000 0.750000
vt 0.750000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.750000
vt 0.875000 1.000000
vt 0.750000 0.500000
vt 0.875000 0.500000
vt 1.000000 0.750000
vt 1.000000 0.500000
vt 0.750000 0.375000
vt 0.812500 0.500000
vt 0.812500 0.375000
vt 0.687500 0.375000
vt 0.687500 0.500000
vt 0.687500 0.000000
vt 0.750000 0.000000
vt 0.812500 0.000000
vt 0.875000 0.375000
vt 0.875000 0.000000
vt 0.125000 0.375000
vt 0.062500 0.375000
vt 0.062500 0.500000
vt 0.125000 0.500000
vt 0.187500 0.375000
vt 0.187500 0.500000
vt 0.000000 0.375000
vt 0.000000 0.000000
vt 0.062500 0.000000
vt 0.187500 0.000000
vt 0.125000 0.000000
vt 0.437500 0.875000
vt 0.437500 1.000000
vt 0.375000 1.000000
vt 0.375000 0.875000
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.656250
vt 0.250000 0.656250
vt 0.500000 0.875000
vt 0.437500 0.656250
vt 0.500000 0.656250
vt 0.375000 0.656250
vt 0.312500 1.000000
usemtl Armor
s off
f 1/1 3/2 4/3 2/4
f 5/5 6/6 1/7 2/4
f 8/6 7/5 4/8 3/9
f 5/5 2/4 4/3 7/10
f 7/10 8/11 6/12 5/5
f 8/11 3/13 1/14 6/12
f 9/15 11/16 12/17 10/18
f 13/19 14/20 9/21 10/18
f 12/22 11/23 16/20 15/19
f 13/19 10/18 12/17 15/24
f 14/22 13/19 15/24 16/25
f 9/26 14/22 16/25 11/27
f 17/28 18/24 19/29 20/30
f 24/31 23/32 22/24 21/28
f 23/31 24/14 20/13 19/33
f 24/31 21/28 17/34 20/33
f 21/28 22/30 18/35 17/34
f 22/30 23/36 19/37 18/35
f 27/30 31/35 30/37 26/36
f 28/28 32/34 31/35 27/30
f 25/31 29/33 32/34 28/28
f 26/31 30/33 29/13 25/14
f 25/31 28/28 27/24 26/32
f 32/28 29/30 30/29 31/24
f 40/38 33/39 34/40 39/41
f 36/42 38/38 37/41 35/43
f 39/44 37/45 38/46 40/39
f 34/1 35/2 37/47 39/42
f 40/38 38/48 36/46 33/39
f 33/42 36/47 35/48 34/38
f 45/38 46/41 42/40 41/39
f 41/42 42/38 43/48 44/47
f 45/38 41/39 44/46 47/48
f 42/1 46/42 48/47 43/2
f 46/44 45/39 47/46 48/45
f 44/42 43/43 48/41 47/38
f 53/49 54/50 49/51 50/52
f 51/53 52/54 50/55 49/56
f 55/57 51/49 49/58 54/59
f 52/52 56/54 53/55 50/60
f 56/49 55/52 54/60 53/58
f 52/52 51/51 55/61 56/54
f 64/49 61/58 62/60 63/52
f 57/52 59/60 61/55 64/54
f 63/57 62/59 60/58 58/49
f 58/53 60/56 59/55 57/54
f 61/49 59/52 60/51 62/50
f 57/52 64/54 63/61 58/51
f 65/15 66/18 68/17 67/16
f 69/19 66/18 65/21 70/20
f 68/22 71/19 72/20 67/23
f 69/19 71/24 68/17 66/18
f 70/22 72/25 71/24 69/19
f 65/26 67/27 72/25 70/22

@ -0,0 +1,191 @@
# Blender v2.73 (sub 0) OBJ File: '3d_armor_stand.blend'
# www.blender.org
mtllib 3d_armor_stand.mtl
o Player_Cube
v 0.062500 1.312500 -0.062500
v 0.062500 1.312500 0.062500
v -0.062500 1.312500 -0.062500
v -0.062500 1.312500 0.062500
v -0.187500 -0.437504 0.062500
v -0.187500 -0.437504 -0.062500
v -0.187500 0.937500 0.062500
v -0.187500 0.937500 -0.062500
v -0.250000 0.250000 0.062500
v -0.250000 0.250000 -0.062500
v -0.250000 0.125003 0.062500
v -0.250000 0.125003 -0.062500
v 0.250000 0.250000 0.062500
v 0.250000 0.250000 -0.062500
v 0.250000 0.125003 0.062500
v 0.250000 0.125003 -0.062500
v -0.062500 -0.437504 -0.062500
v -0.062500 -0.437504 0.062500
v -0.062500 0.937500 0.062500
v -0.062500 0.937500 -0.062500
v 0.062500 0.250000 0.062500
v 0.062500 0.250000 -0.062500
v 0.187500 0.250000 -0.062500
v 0.187500 0.250000 0.062500
v 0.187500 0.937500 -0.062500
v 0.187500 0.937500 0.062500
v 0.187500 -0.437504 -0.062500
v 0.187500 -0.437504 0.062500
v 0.062500 -0.437504 -0.062500
v 0.062500 -0.437504 0.062500
v 0.062500 0.937500 0.062500
v 0.062500 0.937500 -0.062500
v -0.062500 0.812500 -0.062500
v -0.187500 0.812500 -0.062500
v -0.062500 0.812500 0.062500
v -0.187500 0.812500 0.062500
v 0.062500 0.812500 -0.062500
v 0.187500 0.812500 -0.062500
v 0.187500 0.812500 0.062500
v 0.062500 0.812500 0.062500
v 0.375000 0.812500 0.062500
v 0.375000 0.812500 -0.062500
v 0.375000 0.937500 0.062500
v 0.375000 0.937500 -0.062500
v 0.500000 -0.437500 -0.500000
v 0.500000 -0.437500 0.500000
v -0.500000 -0.437500 -0.500000
v -0.500000 -0.437500 0.500000
v -0.062500 0.250000 -0.062500
v -0.187500 0.250000 -0.062500
v -0.062500 0.250000 0.062500
v -0.187500 0.250000 0.062500
v -0.375000 0.937500 0.062500
v -0.375000 0.937500 -0.062500
v -0.375000 0.812500 -0.062500
v -0.375000 0.812500 0.062500
v 0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.187500 0.124998 0.062500
v 0.187500 0.124998 -0.062500
v 0.062500 0.124998 0.062500
v 0.062500 0.124998 -0.062500
v -0.062500 0.124998 -0.062500
v -0.187500 0.124998 -0.062500
v -0.062500 0.124998 0.062500
v -0.187500 0.124998 0.062500
vt 0.000000 0.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.000000 0.250000
vt 0.125000 0.500000
vt 0.125000 0.750000
vt -0.000000 0.750000
vt -0.000000 0.500000
vt 0.750000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.250000
vt 0.750000 0.250000
vt 0.375000 0.500000
vt 0.375000 0.750000
vt 0.875000 0.750000
vt 0.875000 1.000000
vt 0.000000 1.000000
vt 0.875000 0.500000
vt 0.750000 0.500000
vt 1.000000 0.500000
vt 1.000000 0.750000
vt 0.750000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.250000 0.500000
vt 0.250000 0.750000
vt 0.625000 0.250000
vt 0.625000 -0.000000
vt 0.250000 0.250000
vt 0.250000 0.000000
vt 0.375000 0.250000
vt 0.250000 1.000000
vt 1.000000 1.000000
vt 0.750000 1.000000
vt 0.375000 -0.000000
vt 0.125000 0.250000
vt 0.125000 1.000000
vt 0.125000 0.000000
vt -0.000000 0.937500
vt 1.000000 0.937500
vt 0.937500 0.000000
vt 0.937500 1.000000
vt 1.000000 0.062500
vt 0.000000 0.062500
vt 0.062500 0.000000
vt 0.062500 1.000000
g Player_Cube_Stand
usemtl Stand
s off
f 64/1 29/2 30/3 63/4
f 52/5 50/6 10/7 9/8
f 17/9 18/10 5/11 6/12
f 68/3 66/2 6/1 5/4
f 7/13 8/14 54/7 53/8
f 67/15 68/16 5/17 18/7
f 62/4 27/3 29/18 64/8
f 66/3 65/18 17/8 6/4
f 9/19 10/20 12/21 11/22
f 63/7 30/15 28/16 61/17
f 65/18 67/15 18/7 17/8
f 61/8 28/18 27/15 62/7
f 19/23 7/24 36/14 35/25
f 8/14 7/13 19/26 20/25
f 23/15 24/18 13/20 14/21
f 13/8 15/27 16/28 14/7
f 39/29 38/30 42/10 41/11
f 29/31 27/4 28/1 30/32
f 25/28 26/27 43/26 44/25
f 38/12 25/19 44/13 42/33
f 25/28 32/7 31/8 26/27
f 8/26 20/13 33/33 34/29
f 25/19 38/12 37/11 32/20
f 31/17 40/7 39/28 26/34
f 26/34 39/28 41/25 43/23
f 43/7 41/28 42/34 44/17
f 53/22 54/21 55/35 56/36
f 36/14 7/24 53/17 56/7
f 8/26 34/29 55/11 54/20
f 34/37 36/33 56/4 55/1
f 51/13 21/26 22/25 49/14
f 20/4 3/12 1/19 32/8
f 40/15 31/16 19/23 35/25
f 35/29 33/30 37/2 40/3
f 33/33 20/13 32/5 37/38
f 3/14 4/24 2/23 1/25
f 19/12 4/4 3/1 20/9
f 31/36 2/17 4/7 19/22
f 32/22 1/7 2/8 31/19
f 23/5 62/38 64/33 22/13
f 21/14 63/24 61/39 24/6
f 61/3 62/2 16/10 15/11
f 62/38 23/5 14/8 16/4
f 24/6 61/39 15/17 13/7
f 50/18 66/3 12/11 10/20
f 66/40 68/38 11/4 12/1
f 50/18 49/26 65/29 66/3
f 51/25 52/15 68/16 67/23
f 68/16 52/15 9/21 11/35
f 49/26 22/13 64/33 65/29
f 51/25 67/23 63/24 21/14
f 67/33 65/37 64/30 63/29
f 37/1 22/2 21/3 40/4
f 38/4 23/3 22/18 37/8
f 40/7 21/15 24/16 39/17
f 39/8 24/18 23/15 38/7
f 36/2 34/3 50/4 52/1
f 35/15 36/16 52/17 51/7
f 34/3 33/18 49/8 50/4
f 33/18 35/15 51/7 49/8
g Player_Cube_Base
usemtl Base
f 47/17 48/1 46/10 45/35
f 59/1 57/10 58/35 60/17
f 48/17 60/41 58/42 46/35
f 46/43 58/10 57/35 45/44
f 47/1 45/10 57/45 59/46
f 48/47 47/48 59/17 60/1

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

@ -52,3 +52,10 @@ Depends: 3d_armor
Adds tin, silver and technic materials to 3d_armor. Adds tin, silver and technic materials to 3d_armor.
Requires technic mod to be installed for craft registration. Requires technic mod to be installed for craft registration.
[mod] 3d Armor Stand [3d_armor_stand]
-------------------------------------
Depends: 3d_armor
Adds a chest-like armor stand for armor storage and display.