Add new nodes and functional working bench

master
kilbith 2015-06-11 22:06:54 +02:00
parent b707dcbf94
commit 669d495742
23 changed files with 272 additions and 67 deletions

View File

@ -6,6 +6,7 @@
### Credits ###
##### Textures : Gambit, VanessaE, kilbith. #####
##### Code : VanessaE, t4im, kilbith. #####
##### Code : VanessaE, t4im, kilbith, Krock. #####
![Preview](http://i.imgur.com/teTQM6V.png)
![Preview2](http://i.imgur.com/FZzmpep.png)

View File

@ -1,9 +1,20 @@
minetest.register_craft({ output = "xdecor:candle", recipe = {{"default:torch"}} })
minetest.register_craft({ output = "xdecor:cabinet_half 2", recipe = {{"xdecor:cabinet"}} })
minetest.register_craft({ output = "xdecor:cushion 2", recipe = {{"wool:red", "wool:red"}} })
minetest.register_craft({ output = "xdecor:painting", recipe = {{"default:sign_wall", "dye:blue"}} })
minetest.register_craft({ output = "xdecor:moonbrick", recipe = {{"default:brick", "default:stone"}} })
minetest.register_craft({ output = "xdecor:flint_steel", recipe = {{"default:obsidian_shard", "default:steel_ingot"}} })
minetest.register_craft({ output = "xdecor:candle",
recipe = {{"default:torch"}} })
minetest.register_craft({ output = "xdecor:cabinet_half 2",
recipe = {{"xdecor:cabinet"}} })
minetest.register_craft({ output = "xdecor:cushion 2",
recipe = {{"wool:red", "wool:red"}} })
minetest.register_craft({ output = "xdecor:painting",
recipe = {{"default:sign_wall", "dye:blue"}} })
minetest.register_craft({ output = "xdecor:moonbrick",
recipe = {{"default:brick", "default:stone"}} })
minetest.register_craft({ output = "xdecor:flint_steel",
recipe = {{"default:obsidian_shard", "default:steel_ingot"}} })
minetest.register_craft({ output = "xdecor:barrel", recipe = {
{"group:wood", "group:wood", "group:wood"},
@ -28,6 +39,10 @@ minetest.register_craft({ output = "xdecor:chair", recipe = {
{"group:stick", "", ""},
{"group:stick", "group:stick", "group:stick"},
{"group:stick", "", "group:stick"} } })
minetest.register_craft({ output = "xdecor:chandelier", recipe = {
{"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"},
{"default:torch", "default:torch", "default:torch"} } })
minetest.register_craft({ output = "xdecor:coalstone_tile 8", recipe = {
{"default:coalblock", "default:stone"},
@ -46,6 +61,24 @@ minetest.register_craft({ output = "xdecor:frame", recipe = {
{"group:stick", "group:stick", "group:stick"},
{"group:stick", "default:paper", "group:stick"},
{"group:stick", "group:stick", "group:stick"} } })
minetest.register_craft({ output = "xdecor:hammer", recipe = {
{"default:steel_ingot"},
{"group:stick"} } })
minetest.register_craftitem("xdecor:hammer", {
description = "Hammer",
inventory_image = "xdecor_hammer.png"})
minetest.register_craft({ output = "xdecor:lantern", recipe = {
{"default:iron_lump"},
{"default:torch"},
{"default:iron_lump"}} })
minetest.register_craft({ output = "xdecor:metal_cabinet", recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "", ""},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"} } })
minetest.register_craft({ output = "xdecor:multishelf", recipe = {
{"group:wood", "group:wood", "group:wood"},
@ -62,6 +95,11 @@ minetest.register_craft({ output = "xdecor:rope 2", recipe = {
{"farming:string"},
{"farming:string"} } })
minetest.register_craft({ output = "xdecor:stereo", recipe = {
{"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"} } })
minetest.register_craft({ output = "xdecor:stone_tile 2", recipe = {
{"default:cobble", "default:cobble"},
{"default:cobble", "default:cobble"} } })

View File

@ -1 +1,2 @@
default
moreblocks?

View File

@ -5,7 +5,7 @@ local default_can_dig = function(pos,player)
return meta:get_inventory():is_empty("main")
end
local fancy_gui = default.gui_bg..default.gui_bg_img..default.gui_slots
fancy_gui = default.gui_bg..default.gui_bg_img..default.gui_slots
local default_inventory_size = 32
local default_inventory_formspecs = {
["8"]="size[8,6]"..fancy_gui..

View File

@ -6,3 +6,4 @@ dofile(modpath.."/handlers/registration.lua")
dofile(modpath.."/crafts.lua")
dofile(modpath.."/itemframes.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/workbench.lua")

View File

@ -78,7 +78,9 @@ end
xdecor.register("frame", {
description = "Item frame", groups = {snappy=3}, on_rotate = screwdriver.disallow,
node_box = { type = "fixed", fixed = {-0.5, -0.5, 7/16, 0.5, 0.5, 0.5} },
tiles = {"xdecor_frame.png"}, inventory_image = "xdecor_frame.png",
tiles = {"xdecor_wood_tile.png", "xdecor_wood_tile.png", "xdecor_wood_tile.png",
"xdecor_wood_tile.png", "xdecor_wood_tile.png", "xdecor_frame.png"},
inventory_image = "xdecor_frame.png",
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())

163
nodes.lua
View File

@ -5,87 +5,104 @@ xdecor.register("barrel", {
xdecor.register("cabinet", {
description = "Cabinet", inventory = {size=24}, infotext = "Cabinet",
tiles = {"default_wood.png", "xdecor_cabinet_front.png"},
tiles = {"default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png",
"default_wood.png","xdecor_cabinet_front.png"},
groups = {snappy=3}, sounds = default.node_sound_wood_defaults() })
xdecor.register("cabinet_half", {
description = "Half Cabinet", inventory = {size=8}, infotext = "Half Cabinet",
tiles = {"default_wood.png", "xdecor_cabinet_half_front.png"},
tiles = {"default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png",
"default_wood.png", "xdecor_cabinet_half_front.png"},
groups = {snappy=3}, sounds = default.node_sound_wood_defaults(),
node_box = {type="fixed", fixed={{-0.5, 0, -0.5, 0.5, 0.5, 0.5}}} })
xdecor.register("candle", {
description = "Candle", light_source = 12,
inventory_image = "xdecor_candle_inv.png", drawtype = "torchlike",
description = "Candle", light_source = 12, drawtype = "torchlike",
inventory_image = "xdecor_candle_inv.png",
wield_image = "xdecor_candle_inv.png",
paramtype2 = "wallmounted", legacy_wallmounted = true,
walkable = false, groups = {dig_immediate=3, attached_node=1},
tiles = { {name="xdecor_candle_floor.png", animation={type="vertical_frames", length=1.5}},
{name="xdecor_candle_wall.png", animation={type="vertical_frames", length=1.5}} },
tiles = { {name="xdecor_candle_floor.png",
animation={type="vertical_frames", length=1.5}},
{name="xdecor_candle_wall.png",
animation={type="vertical_frames", length=1.5}} },
selection_box = {type="wallmounted",
wall_bottom={-0.25, -0.5, -0.25, 0.25, 0.1, 0.25},
wall_side={-0.5, -0.35, -0.15, -0.15, 0.4, 0.15}} })
xdecor.register("cardboard_box", {
description = "Cardboard Box", groups = {snappy=3}, inventory = {size=8}, infotext = "Cardboard Box",
tiles = {"xdecor_cardbox_top.png", "xdecor_cardbox_top.png", "xdecor_cardbox_sides.png"},
node_box = {type="fixed", fixed={{-0.3125, -0.5, -0.3125, 0.3125, 0, 0.3125}}} })
description = "Cardboard Box", groups = {snappy=3},
inventory = {size=8}, infotext = "Cardboard Box",
tiles = {"xdecor_cardbox_top.png", "xdecor_cardbox_top.png",
"xdecor_cardbox_sides.png"},
node_box = {type="fixed",
fixed={{-0.3125, -0.5, -0.3125, 0.3125, 0, 0.3125}}} })
xdecor.register("cauldron", {
description = "Cauldron", groups = {snappy=1},
tiles = {{name="xdecor_cauldron_top_anim.png",
animation={type="vertical_frames", length=3.0}}, "xdecor_cauldron_sides.png"} })
animation={type="vertical_frames", length=3.0}},
"xdecor_cauldron_sides.png"} })
xdecor.register("chair", {
description = "Chair", tiles = {"xdecor_wood.png"},
description = "Chair", tiles = {"xdecor_wood_tile.png"},
sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
node_box = {type="fixed", fixed={
{-0.3125, -0.5, 0.1875, -0.1875, 0.5, 0.3125}, {0.1875, -0.5, 0.1875, 0.3125, 0.5, 0.3125},
{-0.1875, 0.025, 0.22, 0.1875, 0.45, 0.28}, {-0.3125, -0.5, -0.3125, -0.1875, -0.125, -0.1875},
{0.1875, -0.5, -0.3125, 0.3125, -0.125, -0.1875}, {-0.3125, -0.125, -0.3125, 0.3125, 0, 0.1875}}} })
{-0.3125, -0.5, 0.1875, -0.1875, 0.5, 0.3125},
{0.1875, -0.5, 0.1875, 0.3125, 0.5, 0.3125},
{-0.1875, 0.025, 0.22, 0.1875, 0.45, 0.28},
{-0.3125, -0.5, -0.3125, -0.1875, -0.125, -0.1875},
{0.1875, -0.5, -0.3125, 0.3125, -0.125, -0.1875},
{-0.3125, -0.125, -0.3125, 0.3125, 0, 0.1875}}} })
xdecor.register("chandelier", {
description = "Chandelier", drawtype = "plantlike", walkable = false,
inventory_image = "xdecor_chandelier.png", tiles = {"xdecor_chandelier.png"},
groups = {dig_immediate=3}, light_source = 15 })
xdecor.register("coalstone_tile", {
description = "Coalstone Tile", tiles = {"xdecor_coalstone_tile.png"},
groups = {snappy=3}, sounds = default.node_sound_stone_defaults() })
local curtaincolors = { {"red", "#ad2323e0:175"} } -- add more curtains simply here
for c in ipairs(curtaincolors) do
local color = curtaincolors[c][1]
local hue = curtaincolors[c][2]
xdecor.register("curtain_"..color, {
description = "Curtain ("..color..")", tiles = {"xdecor_curtain.png^[colorize:"..hue},
inventory_image = "xdecor_curtain_open.png^[colorize:"..hue,
local curtaincolors = {"red"} -- add more curtains simply here
for _, c in ipairs(curtaincolors) do
xdecor.register("curtain_"..c, {
description = "Curtain ("..c..")", use_texture_alpha = true, walkable = false,
tiles = {"xdecor_curtain.png^[colorize:"..c..":130"},
inventory_image = "xdecor_curtain_open.png^[colorize:"..c..":130",
wield_image = "xdecor_curtain.png^[colorize:"..c..":130",
drawtype = "signlike", paramtype2 = "wallmounted",
use_texture_alpha = true, walkable = false,
groups = {dig_immediate=3}, selection_box = {type="wallmounted"},
on_rightclick = function(pos, node, clicker, itemstack)
local fdir = node.param2
minetest.set_node(pos, {name = "xdecor:curtain_open_"..color, param2 = fdir})
minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=fdir})
end })
xdecor.register("curtain_open_"..color, {
tiles = { "xdecor_curtain_open.png^[colorize:"..hue },
xdecor.register("curtain_open_"..c, {
tiles = { "xdecor_curtain_open.png^[colorize:"..c..":130" },
drawtype = "signlike", paramtype2 = "wallmounted",
use_texture_alpha = true, walkable = false,
groups = {dig_immediate=3, not_in_creative_inventory=1},
selection_box = {type="wallmounted"}, drop = "xdecor:curtain_"..color,
selection_box = {type="wallmounted"}, drop = "xdecor:curtain_"..c,
on_rightclick = function(pos, node, clicker, itemstack)
local fdir = node.param2
minetest.set_node(pos, { name = "xdecor:curtain_"..color, param2 = fdir })
minetest.set_node(pos, { name="xdecor:curtain_"..c, param2=fdir })
end })
minetest.register_craft({
output = "xdecor:curtain_"..color.." 4",
recipe = {{"", "wool:"..color, ""},
{"", "wool:"..color, ""},
{"", "wool:"..color, ""}} })
output = "xdecor:curtain_"..c.." 4",
recipe = {{"", "wool:"..c, ""},
{"", "wool:"..c, ""},
{"", "wool:"..c, ""}} })
end
xdecor.register("cushion", {
description = "Cushion", tiles = {"xdecor_cushion.png"},
groups = {snappy=3}, on_place = minetest.rotate_node,
node_box = {type="fixed", fixed={{-0.5, -0.5, -0.5, 0.5, 0, 0.5}}} })
xdecor.register("empty_shelf", {
description = "Empty Shelf", inventory = {size=24}, infotext = "Empty Shelf",
tiles = {"default_wood.png", "xdecor_empty_shelf.png"},
@ -98,12 +115,14 @@ xdecor.register("fence_wrought_iron", {
xdecor.register("fire", {
description = "Fake Fire", light_source = 14, walkable = false,
tiles = {{name="xdecor_fire_anim.png", animation={type="vertical_frames", length=1.5}}},
tiles = {{name="xdecor_fire_anim.png",
animation={type="vertical_frames", length=1.5}}},
drawtype = "plantlike", damage_per_second = 2, drop = "",
groups = {dig_immediate=3, not_in_creative_inventory=1} })
minetest.register_tool("xdecor:flint_steel", {
description = "Flint & Steel", stack_max = 1, inventory_image = "xdecor_flint_steel.png",
description = "Flint & Steel", stack_max = 1,
inventory_image = "xdecor_flint_steel.png",
tool_capabilities = {groupcaps={flamable={uses=65, maxlevel=1}}},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" and minetest.get_node(pointed_thing.above).name == "air" then
@ -116,10 +135,23 @@ minetest.register_tool("xdecor:flint_steel", {
return itemstack
end })
xdecor.register("lantern", {
description = "Lantern", light_source = 12, drawtype = "torchlike",
inventory_image = "xdecor_lantern_floor.png",
wield_image = "xdecor_lantern_floor.png",
paramtype2 = "wallmounted", legacy_wallmounted = true,
walkable = false, groups = {dig_immediate=3, attached_node=1},
tiles = {"xdecor_lantern_floor.png", "xdecor_lantern_ceiling.png", "xdecor_lantern.png"},
selection_box = {type="wallmounted",
wall_top = {-0.25, -0.4, -0.25, 0.25, 0.5, 0.25},
wall_bottom = {-0.25, -0.5, -0.25, 0.25, 0.4, 0.25},
wall_side = {-0.5, -0.5, -0.15, 0.5, 0.5, 0.15}} })
flowerstype = {"dandelion_white", "dandelion_yellow", "geranium", "rose", "tulip", "viola"}
for _, f in ipairs(flowerstype) do
xdecor.register("potted_"..f, {
description = "Potted Flowers ("..f..")", walkable = false, groups = {dig_immediate=3},
description = "Potted Flowers ("..f..")", walkable = false,
groups = {dig_immediate=3},
tiles = {"xdecor_"..f.."_pot.png"}, inventory_image = "xdecor_"..f.."_pot.png",
drawtype = "plantlike", sounds = default.node_sound_leaves_defaults() })
@ -129,57 +161,72 @@ minetest.register_craft({
end
xdecor.register("painting", {
description = "Painting", drawtype = "signlike", tiles = {"xdecor_painting.png"},
description = "Painting", drawtype = "signlike",
tiles = {"xdecor_painting.png"}, inventory_image = "xdecor_painting.png",
paramtype2 = "wallmounted", legacy_wallmounted = true, walkable = false,
inventory_image = "xdecor_painting.png", selection_box = {type = "wallmounted"},
groups = {dig_immediate=3, attached_node=1}, sounds = default.node_sound_wood_defaults() })
wield_image = "xdecor_painting.png", selection_box = {type = "wallmounted"},
groups = {dig_immediate=3, attached_node=1},
sounds = default.node_sound_wood_defaults() })
xdecor.register("plant_pot", {
description = "Plant Pot", groups = {snappy=3},
tiles = {"xdecor_plant_pot_top.png", "xdecor_plant_pot_sides.png"} })
xdecor.register("metal_cabinet", {
description = "Metal Cabinet", inventory = {size=24},
tiles = {"xdecor_metal_cabinet_sides.png", "xdecor_metal_cabinet_sides.png",
"xdecor_metal_cabinet_sides.png", "xdecor_metal_cabinet_sides.png",
"xdecor_metal_cabinet_sides.png", "xdecor_metal_cabinet_front.png"},
groups = {snappy=2}, infotext = "Metal Cabinet" })
xdecor.register("moonbrick", {
description = "Moonbrick", tiles = {"xdecor_moonbrick.png"},
groups = {snappy=3}, sounds = default.node_sound_stone_defaults() })
xdecor.register("multishelf", {
description = "Multishelf", inventory = {size=24}, infotext = "Multishelf",
description = "Multi Shelf", inventory = {size=24}, infotext = "Multi Shelf",
tiles = {"default_wood.png", "xdecor_multishelf.png"},
groups = {snappy=3}, sounds = default.node_sound_wood_defaults() })
local rope_sbox = {type="fixed", fixed={-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}}
xdecor.register("rope", {
description = "Rope", walkable = false, climbable = true,
tiles = {"xdecor_rope.png"}, inventory_image = "xdecor_rope_inv.png",
drawtype = "plantlike", groups = {dig_immediate=3}, selection_box = rope_sbox })
description = "Rope", walkable = false, climbable = true,
groups = {dig_immediate=3}, selection_box = rope_sbox,
tiles = {"xdecor_rope.png"}, inventory_image = "xdecor_rope_inv.png",
wield_image = "xdecor_rope_inv.png", drawtype = "plantlike" })
xdecor.register("stereo", {
description = "Stereo", groups = {snappy=3},
tiles = {"xdecor_stereo_top.png", "xdecor_stereo_bottom.png",
"xdecor_stereo_left.png^[transformFX", "xdecor_stereo_left.png",
"xdecor_stereo_back.png", "xdecor_stereo_front.png"} })
xdecor.register("stone_rune", {
description = "Stone Rune", tiles = {"xdecor_stone_rune.png"},
groups = {snappy=3}, sounds = default.node_sound_stone_defaults() })
xdecor.register("stone_tile", {
description = "Stone Tile", tiles = {"xdecor_stone_tile.png"},
groups = {snappy=3}, sounds = default.node_sound_stone_defaults() })
xdecor.register("table", {
description = "Table", tiles = {"xdecor_wood.png"},
description = "Table", tiles = {"xdecor_wood_tile.png"},
groups = {snappy=3}, sounds = default.node_sound_wood_defaults(),
node_box = {type="fixed", fixed={
{-0.5, 0.4, -0.5, 0.5, 0.5, 0.5}, {-0.15, -0.5, -0.15, 0.15, 0.4, 0.15}}} })
{-0.5, 0.4, -0.5, 0.5, 0.5, 0.5},
{-0.15, -0.5, -0.15, 0.15, 0.4, 0.15}}} })
xdecor.register("tv", {
description = "Television", light_source = 11, groups = {snappy=3},
tiles = {"xdecor_television_left.png^[transformR270", "xdecor_television_left.png^[transformR90",
"xdecor_television_left.png^[transformFX", "xdecor_television_left.png",
"xdecor_television_back.png", {name="xdecor_television_front_animated.png",
tiles = {
"xdecor_television_left.png^[transformR270",
"xdecor_television_left.png^[transformR90",
"xdecor_television_left.png^[transformFX",
"xdecor_television_left.png",
"xdecor_television_back.png",
{name="xdecor_television_front_animated.png",
animation = {type="vertical_frames", length=80.0}}} })
xdecor.register("wood_tile", {
description = "Wood Tile", tiles = {"xdecor_wood_tile.png"},
groups = {snappy=3}, sounds = default.node_sound_wood_defaults() })
xdecor.register("workbench", {
description = "Work Bench", inventory = {size=24}, infotext = "Work Bench",
sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
tiles = {"xdecor_workbench_top.png", "xdecor_workbench_top.png", "xdecor_workbench_sides.png", "xdecor_workbench_sides.png",
"xdecor_workbench_front.png", "xdecor_workbench_front.png"} })
groups = {snappy=3, wood=1}, sounds = default.node_sound_wood_defaults() })

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
textures/xdecor_hammer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

BIN
textures/xdecor_lantern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

BIN
textures/xdecor_saw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 220 B

115
workbench.lua Normal file
View File

@ -0,0 +1,115 @@
-- Repair Tool's code by Krock, modified by kilbith
xdecor.register("workbench", {
description = "Work Bench", infotext = "Work Bench",
sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
tiles = {"xdecor_workbench_top.png", "xdecor_workbench_top.png",
"xdecor_workbench_sides.png", "xdecor_workbench_sides.png",
"xdecor_workbench_front.png", "xdecor_workbench_front.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,7;]"..fancy_gui..
"label[0,0;Cut your wood into...]"..
"label[0,1.5;Input]"..
"list[current_name;input;0,2;1,1;]"..
"image[1,2;1,1;xdecor_saw.png]"..
"label[2,1.5;Output]"..
"list[current_name;output;2,2;1,1;]"..
"label[5.5,0;Damaged tool]"..
"list[current_name;src;6,0.5;1,1;]"..
"image[4.35,1.1;1.5,1.5;xdecor_hammer.png]"..
"label[5.8,1.5;Hammer]]"..
"list[current_name;fuel;6,2;1,1;]"..
"item_image_button[0,0.5;1,1;xdecor:microslab_wood;microslab; ]"..
"item_image_button[1,0.5;1,1;xdecor:microslab_half_wood;microslabhalf; ]"..
"item_image_button[2,0.5;1,1;xdecor:microcube_wood;microcube; ]"..
"item_image_button[3,0.5;1,1;xdecor:panel_wood;panel; ]"..
"list[current_player;main;0,3.25;8,4;]")
meta:set_string("infotext", "Work Bench")
local inv = meta:get_inventory()
inv:set_size("output", 1)
inv:set_size("input", 1)
inv:set_size("src", 1)
inv:set_size("fuel", 1)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local shape = {}
local anz = 0
if fields["microslab"] then
anz = "8"
shape = "xdecor:microslab_wood"
elseif fields["microslabhalf"] then
anz = "16"
shape = "xdecor:microslab_half_wood"
elseif fields["microcube"] then
anz = "8"
shape = "xdecor:microcube_wood"
elseif fields["panel"] then
anz = "4"
shape = "xdecor:panel_wood"
else return end
local inputstack = inv:get_stack("input", 1)
if minetest.get_item_group(inputstack:get_name(), "wood") ~= 0 then
local give = {}
for i = 0, anz-1 do
give[i+1] = inv:add_item("output", shape)
end
inputstack:take_item()
inv:set_stack("input", 1, inputstack)
else return end
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("src") and inv:is_empty("fuel")
and inv:is_empty("input") and inv:is_empty("output")
end
})
local function register_wood_cut(name, desc, box, f_groups)
f_groups = {}
f_groups.snappy = 3
f_groups.not_in_creative_inventory = 1
xdecor.register(name.."_wood", {
description = "Wood "..desc,
tiles = {"xdecor_wood_tile.png"}, groups = f_groups,
sounds = default.node_sound_wood_defaults(),
node_box = { type = "fixed", fixed = box } }) end
wood = {}
wood.datas = {
{"microslab", "Microslab", { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 }},
{"microslab_half", "Half Microslab", { -0.5, -0.5, -0.5, 0.5, -0.4375, 0 }},
{"microcube", "Microcube", { -0.5, -0.5, -0.5, 0, 0, 0 }},
{"panel", "Panel", { -0.5, -0.5, -0.5, 0.5, 0, 0 }},
}
for _, item in pairs(wood.datas) do
register_wood_cut(unpack(item))
end
minetest.register_abm({
nodenames = {"xdecor:workbench"},
interval = 5, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local src = inv:get_stack("src", 1)
local wear = src:get_wear()
local repair = -1400
if (src:is_empty() or wear == 0 or wear == 65535) then return end
local fuel = inv:get_stack("fuel", 1)
if (fuel:is_empty() or fuel:get_name() ~= "xdecor:hammer") then return end
if (wear + repair < 0) then src:add_wear(repair + wear)
else src:add_wear(repair) end
inv:set_stack("src", 1, src)
inv:remove_item("fuel", "xdecor:hammer 1")
end
})