Rakes have gone metal too now
This commit is contained in:
parent
5556797e45
commit
c57515a072
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ipairs, minetest, nodecore, pairs, table, vector
|
||||
= ipairs, minetest, nodecore, pairs, table, vector
|
||||
local table_sort
|
||||
= table.sort
|
||||
local ipairs, math, minetest, nodecore, pairs, table, vector
|
||||
= ipairs, math, minetest, nodecore, pairs, table, vector
|
||||
local math_abs, math_max, table_sort
|
||||
= math.abs, math.max, table.sort
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
-- To register a tool as a rake, provie a callback:
|
||||
@ -23,6 +23,8 @@ for dy = -dymax, dymax do
|
||||
for dz = -dxzmax, dxzmax do
|
||||
local v = {x = dx, y = dy, z = dz}
|
||||
v.d = vector.length(v)
|
||||
v.rxz = math_max(math_abs(dx), math_abs(dz))
|
||||
v.ry = math_abs(dy)
|
||||
rakepos[#rakepos + 1] = v
|
||||
end
|
||||
end
|
||||
@ -59,7 +61,7 @@ local function dorake(pos, node, user, ...)
|
||||
for _, rel in ipairs(rakepos) do
|
||||
local p = vector.add(pos, rel)
|
||||
local n = minetest.get_node(p)
|
||||
local allow = lastraking(n.name, rel, p)
|
||||
local allow = (rel.d > 0 or nil) and lastraking(n.name, rel, p)
|
||||
if allow == false then break end
|
||||
if allow and ((not sneak) or matching(pos, node, p, n)) then
|
||||
minetest.node_dig(p, n, user, ...)
|
||||
@ -82,9 +84,8 @@ local rakelock = {}
|
||||
nodecore.register_on_dignode("rake handling", function(pos, node, user, ...)
|
||||
if not lastraking then return end
|
||||
|
||||
if not (pos and node and node.name and lastraking(node.name, {
|
||||
x = 0, y = 0, z = 0, d = 0
|
||||
}, pos)) then return end
|
||||
if not (pos and node and node.name
|
||||
and lastraking(node.name, rakepos[1], pos)) then return end
|
||||
if not user:is_player() then return end
|
||||
|
||||
local pname = user:get_player_name()
|
||||
|
@ -11,4 +11,5 @@ include("oresmelt")
|
||||
include("tools")
|
||||
include("shafts")
|
||||
include("adze")
|
||||
include("rake")
|
||||
include("shelf")
|
||||
|
71
mods/nc_lode/rake.lua
Normal file
71
mods/nc_lode/rake.lua
Normal file
@ -0,0 +1,71 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, pairs
|
||||
= minetest, nodecore, pairs
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local rakable = {}
|
||||
minetest.after(0, function()
|
||||
for k, v in pairs(minetest.registered_nodes) do
|
||||
if v.groups then
|
||||
if v.groups.damage_touch then
|
||||
rakable[k] = nil
|
||||
elseif v.groups.snappy == 1 then
|
||||
rakable[k] = true
|
||||
elseif v.groups.crumbly then
|
||||
rakable[k] = v.groups.crumbly
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
nodecore.register_lode("rake", {
|
||||
type = "tool",
|
||||
description = "## Lode Rake",
|
||||
inventory_image = modname .. "_#.png^[mask:" .. modname .. "_rake.png",
|
||||
stack_max = 1,
|
||||
light_source = 3,
|
||||
bytemper = function(t, d)
|
||||
local dlv = 0
|
||||
if t.name == "tempered" then
|
||||
dlv = 1
|
||||
elseif t.name == "hot" then
|
||||
dlv = -1
|
||||
end
|
||||
d.tool_capabilities = nodecore.toolcaps({
|
||||
snappy = 1,
|
||||
crumbly = 1 + dlv,
|
||||
uses = 20 + 5 * dlv
|
||||
})
|
||||
d.rake_check = function(itemname, rel)
|
||||
local r = rakable[itemname]
|
||||
if not r then return end
|
||||
if r == true then return true end
|
||||
if rel.rxz > 1 or rel.ry > 0 then return end
|
||||
return r <= (1 + dlv) or nil
|
||||
end
|
||||
end,
|
||||
tool_wears_to = modname .. ":prill_# 3"
|
||||
})
|
||||
|
||||
local adze = {name = modname .. ":adze_annealed", wear = 0.05}
|
||||
nodecore.register_craft({
|
||||
label = "assemble lode rake",
|
||||
action = "pummel",
|
||||
toolgroups = {thumpy = 3},
|
||||
norotate = true,
|
||||
priority = 1,
|
||||
indexkeys = {modname .. ":bar_annealed"},
|
||||
nodes = {
|
||||
{match = modname .. ":bar_annealed", replace = "air"},
|
||||
{y = -1, match = modname .. ":block_tempered"},
|
||||
{x = 0, z = -1, match = adze, replace = "air"},
|
||||
{x = 0, z = 1, match = adze, replace = "air"},
|
||||
{x = -1, z = 0, match = adze, replace = "air"},
|
||||
{x = 1, z = 0, match = adze, replace = "air"},
|
||||
},
|
||||
items = {
|
||||
modname .. ":rake_annealed"
|
||||
}
|
||||
})
|
BIN
mods/nc_lode/textures/nc_lode_rake.png
Normal file
BIN
mods/nc_lode/textures/nc_lode_rake.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 118 B |
Loading…
x
Reference in New Issue
Block a user