Add initial furniture_api code

master
Benrob0329 2019-06-12 03:55:33 +00:00
parent 7cc03e2382
commit 0411c32e9c
9 changed files with 1504 additions and 0 deletions

View File

@ -0,0 +1,91 @@
furniture = {}
kit_default = {
description = "Default Description For Furniture Kits",
mesh = "error.obj",
tiles = {"unknown_node.png^[colorize:#ff0000:255"},
-- Box Specific Options
box_contents = {},
box_tiles = {
{name = "furniture_api_box_top.png", backface_culling = false},
{name = "furniture_api_box_bottom.png", backface_culling = false},
{name = "furniture_api_box_side.png", backface_culling = false},
{name = "furniture_api_box_side.png", backface_culling = false},
{name = "furniture_api_box_front.png", backface_culling = false},
{name = "furniture_api_box_front.png", backface_culling = false},
},
box_open_tiles = {
{name = "furniture_api_box_top.png^[opacity:0", backface_culling = false},
{name = "furniture_api_box_bottom.png", backface_culling = false},
{name = "furniture_api_box_side.png", backface_culling = false},
{name = "furniture_api_box_side.png", backface_culling = false},
{name = "furniture_api_box_back_open.png", backface_culling = false},
{name = "furniture_api_box_front_open.png", backface_culling = false},
},
}
function furniture.register_kit(name, def)
if def == nil then
def = {}
end
-- Furniture Node
minetest.register_node(":" .. name, {
description = (def.description or kit_default.description),
paramtype = "light",
paramtype2 = "facedir",
drawtype = "mesh",
mesh = (def.mesh or kit_default.mesh),
tiles = (def.tiles or kit_default.tiles),
groups = {carryable = 1},
})
-- Box Node
minetest.register_node(":" .. name .. "_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = { -6/16, -0.499, -6/16, 6/16, 4/16, 6/16 },
},
description = (def.description or kit_default.description),
paramtype = "light",
paramtype2 = "facedir",
tiles = (def.box_tiles or kit_default.box_tiles),
use_texture_alpha = true,
groups = {carryable = 1},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
minetest.set_node(pos, {name = name.."_box_open"})
end
})
-- Opened Box Node
minetest.register_node(":" .. name .. "_box_open", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = { -6/16, -0.499, -6/16, 6/16, 8/16, 6/16 },
},
description = (def.description or kit_default.description),
paramtype = "light",
paramtype2 = "facedir",
tiles = (def.box_open_tiles or kit_default.box_open_tiles),
use_texture_alpha = true,
groups = {carryable = 1},
on_construct = function(pos)
for k, v in pairs(def.box_contents) do
vel = math.random(5, 8)
core.spawn_item(pos, v):set_velocity({x=0,y=vel,z=0})
end
minetest.get_node_timer(pos):start(5)
end,
on_timer = function(pos)
minetest.set_node(pos, {name = "air"})
end,
})
end

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB