Use adze to split logs into planks.
This commit is contained in:
parent
90c7d2daaf
commit
7bd9c4e63a
@ -3,16 +3,12 @@ local minetest
|
||||
= minetest
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
nodecore.last_player_node_punch = nodecore.last_player_node_punch or {}
|
||||
|
||||
local pummeling = {}
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, puncher, pointed)
|
||||
if not puncher:is_player() then return end
|
||||
local pname = puncher:get_player_name()
|
||||
|
||||
nodecore.last_player_node_punch[pname] = pointed
|
||||
|
||||
node = node or minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not def.on_pummel then return end
|
||||
|
@ -43,6 +43,14 @@ function nodecore.pickrand(tbl, weight)
|
||||
end
|
||||
end
|
||||
|
||||
function nodecore.extend_node(name, func)
|
||||
local orig = minetest.registered_nodes[name]
|
||||
local copy = {}
|
||||
for k, v in pairs(orig) do copy[k] = v end
|
||||
copy = func(copy, orig) or copy
|
||||
minetest.register_node(":" .. name, copy)
|
||||
end
|
||||
|
||||
function nodecore.fixedbox(...) return {type = "fixed", fixed = {...}} end
|
||||
|
||||
local path = minetest.get_modpath(modname)
|
||||
|
@ -3,15 +3,16 @@ local minetest
|
||||
= minetest
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local minetest = minetest
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:get_inventory():set_size("main", 8)
|
||||
player:hud_set_hotbar_itemcount(8)
|
||||
|
||||
player:hud_set_hotbar_image("nc_hud_bg.png")
|
||||
player:hud_set_hotbar_selected_image("nc_hud_sel.png")
|
||||
|
||||
player:set_inventory_formspec("size[8,1]"
|
||||
.. "bgcolor[#000000C0;true]"
|
||||
.. "background[0,0;8,1;nc_inv_bg.png;true]"
|
||||
.. "listcolors[#00000000;#00000000;#00000000]"
|
||||
.. "list[current_player;main;0,0;8,1;]")
|
||||
player:hud_set_hotbar_itemcount(8)
|
||||
player:hud_set_hotbar_image("nc_hud_bg.png")
|
||||
player:hud_set_hotbar_selected_image("nc_hud_sel.png")
|
||||
end)
|
||||
|
@ -30,8 +30,7 @@ minetest.register_node(modname .. ":stack", {
|
||||
minetest.item_drop(stack, nil, posto)
|
||||
end
|
||||
return minetest.remove_node(posfrom)
|
||||
end,
|
||||
on_punch = function() end
|
||||
end
|
||||
})
|
||||
|
||||
local function buildable_to(pos)
|
||||
@ -62,6 +61,7 @@ local item = {
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
end,
|
||||
on_punch = function() end
|
||||
}
|
||||
setmetatable(item, bii)
|
||||
minetest.register_entity(":__builtin:item", item)
|
||||
|
@ -1,14 +0,0 @@
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
minetest.register_tool(modname .. ":adze", {
|
||||
description = "Wooden Adze",
|
||||
inventory_image = modname .. "_adze.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.2,
|
||||
groupcaps = {
|
||||
choppy = {times={[3]=1.60}, uses=20, maxlevel=1},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
nodecore.staff_tool_recipes[modname .. ":stick"] = modname .. ":adze"
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
local minetest, nodecore, pairs
|
||||
= minetest, nodecore, pairs
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local error, ipairs, minetest
|
||||
= error, ipairs, minetest
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
minetest.register_decoration({
|
||||
|
@ -12,7 +12,6 @@ local path = minetest.get_modpath(modname)
|
||||
dofile(path .. "/node.lua")
|
||||
|
||||
dofile(path .. "/sticks.lua")
|
||||
dofile(path .. "/adze.lua")
|
||||
|
||||
dofile(path .. "/schematic.lua")
|
||||
dofile(path .. "/decor.lua")
|
||||
|
@ -23,7 +23,23 @@ minetest.register_node(modname .. ":tree", {
|
||||
},
|
||||
groups = {
|
||||
choppy = 3
|
||||
}
|
||||
},
|
||||
drop = modname .. ":log"
|
||||
})
|
||||
|
||||
minetest.register_node(modname .. ":log", {
|
||||
description = "Tree",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {
|
||||
modname .. "_tree_top.png",
|
||||
modname .. "_tree_top.png",
|
||||
modname .. "_tree_side.png"
|
||||
},
|
||||
groups = {
|
||||
choppy = 4,
|
||||
falling_node = 1
|
||||
},
|
||||
on_place = minetest.rotate_and_place
|
||||
})
|
||||
|
||||
minetest.register_node(modname .. ":leaves", {
|
||||
|
@ -1,3 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local error, ipairs, minetest, nodecore
|
||||
= error, ipairs, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function ezschem(key, yslices, init)
|
||||
|
19
mods/nc_woodwork/adze.lua
Normal file
19
mods/nc_woodwork/adze.lua
Normal file
@ -0,0 +1,19 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
minetest.register_tool(modname .. ":adze", {
|
||||
description = "Wooden Adze",
|
||||
inventory_image = modname .. "_adze.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.2,
|
||||
groupcaps = {
|
||||
choppy = {times={[3]=6.00, [4]=3.00}, uses=5, maxlevel=1},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
nodecore.staff_tool_recipes["nc_tree:stick"] = modname .. ":adze"
|
2
mods/nc_woodwork/depends.txt
Normal file
2
mods/nc_woodwork/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
nc_api
|
||||
nc_tree
|
10
mods/nc_woodwork/init.lua
Normal file
10
mods/nc_woodwork/init.lua
Normal file
@ -0,0 +1,10 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local dofile, minetest
|
||||
= dofile, minetest
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
local path = minetest.get_modpath(modname)
|
||||
|
||||
dofile(path .. "/adze.lua")
|
||||
dofile(path .. "/plank.lua")
|
53
mods/nc_woodwork/plank.lua
Normal file
53
mods/nc_woodwork/plank.lua
Normal file
@ -0,0 +1,53 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, ipairs, minetest, nodecore
|
||||
= ItemStack, ipairs, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local plank = modname .. ":plank"
|
||||
minetest.register_node(plank, {
|
||||
description = "Wooden Plank",
|
||||
tiles = { modname .. "_plank.png" },
|
||||
groups = {
|
||||
choppy = 3
|
||||
}
|
||||
})
|
||||
|
||||
local upright = {[0]=true,[1]=true,[2]=true,[3]=true,[20]=true,[21]=true,[22]=true,[23]=true}
|
||||
for _, name in ipairs({"nc_tree:tree", "nc_tree:log"}) do
|
||||
nodecore.extend_node(name, function(copy, orig)
|
||||
local op = orig.on_pummel or function() end
|
||||
copy.on_pummel = function(pos, node, stats, ...)
|
||||
if not upright[node.param2]
|
||||
or (stats.pointed.above.y - stats.pointed.under.y) ~= 1
|
||||
or stats.duration < 5 then
|
||||
return op(pos, node, stats, ...)
|
||||
end
|
||||
local wielded = stats.puncher:get_wielded_item()
|
||||
local caps = wielded:get_tool_capabilities()
|
||||
local choppy = caps and caps.groupcaps and caps.groupcaps.choppy
|
||||
if not choppy then
|
||||
return op(pos, node, stats, ...)
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
local defer = 0
|
||||
for _, v in ipairs({
|
||||
{x = pos.x + 1, y = pos.y, z = pos.z},
|
||||
{x = pos.x - 1, y = pos.y, z = pos.z},
|
||||
{x = pos.x, y = pos.y, z = pos.z + 1},
|
||||
{x = pos.x, y = pos.y, z = pos.z - 1}
|
||||
}) do
|
||||
if minetest.registered_nodes[minetest.get_node(v)
|
||||
.name].buildable_to then
|
||||
minetest.item_drop(ItemStack(plank), nil, v)
|
||||
else
|
||||
defer = defer + 1
|
||||
end
|
||||
end
|
||||
if defer > 0 then
|
||||
minetest.item_drop(ItemStack(plank .. " " .. defer), nil, pos)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B |
BIN
mods/nc_woodwork/textures/nc_woodwork_plank.png
Normal file
BIN
mods/nc_woodwork/textures/nc_woodwork_plank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 272 B |
Loading…
x
Reference in New Issue
Block a user