TOOL CAPABILITIES / LEVELS OVERHAUL
Try to standardize the way we handle tools, materials, digtimes. - Levels start at 1 and work upwards. - Level 1 is for "hand" or "primitive" tools. - Levels 2+ are wood, stone, metal, etc. - Link dig times, tool levels, and durability together. - Material groups now define standard "base dig times" which are the main thing that makes e.g. stone harder to dig than dirt. The speed of digging almost everything will probably have changed, in some cases not for the better; much testing will be needed.
This commit is contained in:
parent
7080270e56
commit
8e47b687d0
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, vector
|
||||
= minetest, nodecore, vector
|
||||
local minetest, nodecore, pairs, vector
|
||||
= minetest, nodecore, pairs, vector
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local pummeling = {}
|
||||
|
@ -15,6 +15,7 @@ dofile(path .. "/util_misc.lua")
|
||||
dofile(path .. "/util_scan_flood.lua")
|
||||
dofile(path .. "/util_logtrace.lua")
|
||||
dofile(path .. "/util_node_is.lua")
|
||||
dofile(path .. "/util_toolcaps.lua")
|
||||
|
||||
dofile(path .. "/register_craft.lua")
|
||||
dofile(path .. "/register_limited_abm.lua")
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, pairs, type
|
||||
= minetest, nodecore, pairs, type
|
||||
= minetest, nodecore, pairs, type
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
--[[
|
||||
@ -16,13 +16,10 @@ local looseimg = "^nc_api_loose.png"
|
||||
|
||||
local function can_repack(level)
|
||||
return function(pos, node, stats)
|
||||
local wield = stats.puncher:get_wielded_item()
|
||||
if not wield then return end
|
||||
local dg = wield:get_tool_capabilities().groupcaps
|
||||
return dg and dg.thumpy and dg.thumpy
|
||||
and dg.thumpy.times[level]
|
||||
return nodecore.toolspeed(stats.puncher:get_wielded_item(), {thumpy = level})
|
||||
end
|
||||
end
|
||||
|
||||
local function pummel_repack_node(mult, replace)
|
||||
if type(replace) ~= "table" then replace = {name = replace} end
|
||||
return function (pos, node, stats)
|
||||
@ -65,7 +62,7 @@ nodecore.register_on_register_item(function(name, def)
|
||||
|
||||
if loose.groups.crumbly and not loose.no_repack then
|
||||
loose.can_pummel = loose.can_pummel
|
||||
or can_repack(loose.repack_level or 3)
|
||||
or can_repack(loose.repack_level or 1)
|
||||
loose.on_pummel = loose.on_pummel
|
||||
or pummel_repack_node(loose.repack_time or 1, name)
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math, minetest, nodecore, pairs, type
|
||||
= math, minetest, nodecore, pairs, type
|
||||
local math_random
|
||||
= math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math, minetest, nodecore, pairs, type
|
||||
= math, minetest, nodecore, pairs, type
|
||||
local math_floor, math_random, math_sqrt
|
||||
= math.floor, math.random, math.sqrt
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
@ -1,7 +1,12 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, pairs
|
||||
= minetest, nodecore, pairs
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
if def.oldnames then
|
||||
for k, v in pairs(def.oldnames) do
|
||||
minetest.register_alias(v, name)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
25
mods/nc_api/item_tool_wears_to.lua
Normal file
25
mods/nc_api/item_tool_wears_to.lua
Normal file
@ -0,0 +1,25 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, minetest, nodecore
|
||||
= ItemStack, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local function wearto(item)
|
||||
return function(what, who, node, dp)
|
||||
what:add_wear(dp.wear)
|
||||
if what:get_count() == 0 then
|
||||
if def.sound and def.sound.breaks then
|
||||
minetest.sound_play(def.sound.breaks,
|
||||
{pos = who:get_pos(), gain = 0.5})
|
||||
end
|
||||
return ItemStack(item)
|
||||
end
|
||||
return what
|
||||
end
|
||||
end
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
if def.tool_wears_to then
|
||||
def.after_use = def.after_use or
|
||||
wearto(def.tool_wears_to)
|
||||
end
|
||||
end)
|
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, ipairs, math, minetest, nodecore, pairs, type
|
||||
= ItemStack, ipairs, math, minetest, nodecore, pairs, type
|
||||
= ItemStack, ipairs, math, minetest, nodecore, pairs, type
|
||||
local math_random
|
||||
= math.random
|
||||
= math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
for k, v in pairs(minetest) do
|
||||
@ -121,6 +121,22 @@ function nodecore.wear_current_tool(player, groups, qty)
|
||||
end
|
||||
end
|
||||
|
||||
function nodecore.toolspeed(wield, groups)
|
||||
if not wield then return end
|
||||
local dg = wield:get_tool_capabilities().groupcaps
|
||||
local t
|
||||
for gn, lv in pairs(groups) do
|
||||
local gt = dg[gn]
|
||||
gt = gt and gt.times
|
||||
gt = gt and gt[lv]
|
||||
if not t or t > gt then t = gt end
|
||||
end
|
||||
if not t and not wield:is_empty() then
|
||||
return nodecore.toolspeed(ItemStack(""), groups)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
function nodecore.loaded_mods()
|
||||
local t = {}
|
||||
for _, v in pairs(minetest.get_modnames()) do
|
||||
|
35
mods/nc_api/util_toolcaps.lua
Normal file
35
mods/nc_api/util_toolcaps.lua
Normal file
@ -0,0 +1,35 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, nodecore, pairs
|
||||
= math, nodecore, pairs
|
||||
local math_pow
|
||||
= math.pow
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local basetimes = {
|
||||
cracky = 3,
|
||||
thumpy = 2,
|
||||
choppy = 0.7,
|
||||
crumbly = 0.5,
|
||||
snappy = 0.4,
|
||||
}
|
||||
|
||||
function nodecore.toolcaps(opts)
|
||||
if opts.uses == nil then opts.uses = 1 end
|
||||
local gcaps = {}
|
||||
for gn, bt in pairs(basetimes) do
|
||||
local lv = opts[gn]
|
||||
if lv then
|
||||
local times = {}
|
||||
for n = 1, 5 do
|
||||
times[n] = math_pow(lv > n and 0.75 or 0.25,
|
||||
lv - n) * bt
|
||||
end
|
||||
gcaps[gn] = {
|
||||
times = times,
|
||||
uses = 5 * math_pow(3, lv) * opts.uses,
|
||||
maxlevel = lv
|
||||
}
|
||||
end
|
||||
end
|
||||
return { groupcaps = gcaps }
|
||||
end
|
@ -1,21 +1,18 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, type
|
||||
= minetest, type
|
||||
local minetest, nodecore, type
|
||||
= minetest, nodecore, type
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "nc_hand.png",
|
||||
wield_scale = {x=1, y=1, z=2.5},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
|
||||
snappy = {times={[2]=2.00, [3]=0.40}, uses=0, maxlevel=1},
|
||||
thumpy = {times={[3]=3.00}, uses=0, maxlevel=1},
|
||||
}
|
||||
}
|
||||
tool_capabilities = nodecore.toolcaps({
|
||||
uses = 0,
|
||||
crumbly = 1,
|
||||
snappy = 1,
|
||||
thumpy = 1
|
||||
})
|
||||
})
|
||||
|
||||
local function cheat() return {times={[1]=0.25, [2]=0.25, [3]=0.25}, uses=0} end
|
||||
@ -23,14 +20,12 @@ minetest.register_tool("nc_hand:cheat", {
|
||||
inventory_image = "nc_hand.png^[invert:rgb",
|
||||
wield_image = "nc_hand.png^[invert:rgb",
|
||||
wield_scale = {x=1, y=1, z=2.5},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
groupcaps = {
|
||||
crumbly = cheat(),
|
||||
cracky = cheat(),
|
||||
snappy = cheat(),
|
||||
choppy = cheat(),
|
||||
thumpy = cheat(),
|
||||
}
|
||||
}
|
||||
tool_capabilities = nodecore.toolcaps({
|
||||
uses = 0,
|
||||
crumbly = 100,
|
||||
cracky = 100,
|
||||
snappy = 100,
|
||||
choppy = 100,
|
||||
thumpy = 100
|
||||
})
|
||||
})
|
||||
|
@ -32,7 +32,7 @@ minetest.register_node(modname .. ":stack", {
|
||||
drop = {},
|
||||
groups = {
|
||||
flammable = 1,
|
||||
crumbly = 3,
|
||||
snappy = 1,
|
||||
falling_repose = 1,
|
||||
visinv = 1
|
||||
},
|
||||
|
@ -10,7 +10,7 @@ local function reg(suff, def)
|
||||
description = "Lode " .. suff,
|
||||
name = suff:lower(),
|
||||
is_ground_content = true,
|
||||
groups = { cracky = 3 }
|
||||
groups = { cracky = 2 }
|
||||
})
|
||||
def.fullname = modname .. ":" .. def.name
|
||||
def.oldnames = {"nc_iron:" .. def.name}
|
||||
@ -34,7 +34,7 @@ reg("Cobble", {
|
||||
repack_level = 2,
|
||||
groups = {
|
||||
cracky = 0,
|
||||
crumbly = 2,
|
||||
crumbly = 1,
|
||||
falling_repose = 3
|
||||
}
|
||||
}
|
||||
|
2
mods/nc_stonework/depends.txt
Normal file
2
mods/nc_stonework/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
nc_terrain
|
||||
nc_woodwork
|
1
mods/nc_stonework/init.lua
Normal file
1
mods/nc_stonework/init.lua
Normal file
@ -0,0 +1 @@
|
||||
|
@ -56,7 +56,7 @@ regterrain({
|
||||
"mese",
|
||||
},
|
||||
groups = {
|
||||
cracky = 3
|
||||
cracky = 2
|
||||
},
|
||||
drop_in_place = modname .. ":cobble",
|
||||
})
|
||||
@ -72,7 +72,7 @@ regterrain({
|
||||
"mossycobble"
|
||||
},
|
||||
groups = {
|
||||
cracky = 3
|
||||
cracky = 1
|
||||
},
|
||||
alternate_loose = {
|
||||
repack_level = 2,
|
||||
@ -103,7 +103,6 @@ regterrain({
|
||||
description = "Dirt",
|
||||
alternate_loose = {
|
||||
groups = {
|
||||
crumbly = 3,
|
||||
falling_repose = 2
|
||||
}
|
||||
},
|
||||
@ -112,7 +111,7 @@ regterrain({
|
||||
"ice",
|
||||
},
|
||||
groups = {
|
||||
crumbly = 3
|
||||
crumbly = 1
|
||||
}
|
||||
})
|
||||
regterrain({
|
||||
@ -127,7 +126,7 @@ regterrain({
|
||||
"dirt_with_snow"
|
||||
},
|
||||
groups = {
|
||||
crumbly = 3
|
||||
crumbly = 2
|
||||
},
|
||||
drop_in_place = modname .. ":dirt"
|
||||
})
|
||||
@ -148,12 +147,11 @@ regterrain({
|
||||
description = "Sand",
|
||||
alternate_loose = {
|
||||
groups = {
|
||||
crumbly = 3,
|
||||
falling_repose = 1
|
||||
}
|
||||
},
|
||||
groups = {
|
||||
crumbly = 3,
|
||||
crumbly = 1,
|
||||
falling_node = 1
|
||||
},
|
||||
mapgen = {
|
||||
|
@ -15,7 +15,7 @@ minetest.register_node(modname .. ":eggcorn", {
|
||||
inventory_image = modname .. "_eggcorn.png",
|
||||
tiles = { modname .. "_eggcorn.png" },
|
||||
groups = {
|
||||
snappy = 3,
|
||||
snappy = 1,
|
||||
flammable = 3,
|
||||
falling_repose = 1
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ minetest.register_node(modname .. ":leaves", {
|
||||
paramtype = "light",
|
||||
tiles = { modname .. "_leaves.png" },
|
||||
groups = {
|
||||
snappy = 2,
|
||||
snappy = 1,
|
||||
flammable = 3,
|
||||
fire_fuel = 2
|
||||
},
|
||||
@ -46,9 +46,7 @@ minetest.register_node(modname .. ":leaves", {
|
||||
tiles = { modname .. "_leaves_dry.png" },
|
||||
walkable = false,
|
||||
groups = {
|
||||
snappy = 3,
|
||||
flammable = 1,
|
||||
fire_fuel = 2,
|
||||
falling_repose = 1
|
||||
}
|
||||
},
|
||||
|
@ -19,7 +19,7 @@ minetest.register_node(modname .. ":stick", {
|
||||
paramtype = "light",
|
||||
groups = {
|
||||
shafty = 1,
|
||||
snappy = 2,
|
||||
snappy = 1,
|
||||
flammable = 2,
|
||||
falling_repose = 1
|
||||
}
|
||||
|
@ -11,12 +11,9 @@ minetest.register_tool(modname .. ":adze", {
|
||||
groups = {
|
||||
flammable = 2
|
||||
},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.2,
|
||||
groupcaps = {
|
||||
choppy = {times={[3]=6.00, [4]=3.00}, uses=5, maxlevel=1},
|
||||
}
|
||||
},
|
||||
tool_capabilities = nodecore.toolcaps({
|
||||
choppy = 1
|
||||
})
|
||||
})
|
||||
|
||||
nodecore.register_craft({
|
||||
|
@ -10,7 +10,7 @@ minetest.register_node(plank, {
|
||||
description = "Wooden Plank",
|
||||
tiles = { modname .. "_plank.png" },
|
||||
groups = {
|
||||
choppy = 3,
|
||||
choppy = 1,
|
||||
flammable = 2,
|
||||
fire_fuel = 5
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ minetest.register_node(modname .. ":staff", {
|
||||
paramtype = "light",
|
||||
groups = {
|
||||
shafty = 2,
|
||||
snappy = 2,
|
||||
snappy = 1,
|
||||
flammable = 2,
|
||||
falling_repose = 2
|
||||
}
|
||||
|
@ -26,18 +26,9 @@ local function toolhead(name, from, group, sticks, times)
|
||||
groups = {
|
||||
flammable = 2
|
||||
},
|
||||
tool_capabilities = {
|
||||
groupcaps = {
|
||||
[group] = {
|
||||
times = times or {
|
||||
[1] = 4.00,
|
||||
[2] = 1.00,
|
||||
[3] = 0.50
|
||||
},
|
||||
uses = 20
|
||||
},
|
||||
},
|
||||
},
|
||||
tool_capabilities = nodecore.toolcaps({
|
||||
[group] = 2
|
||||
})
|
||||
})
|
||||
nodecore.register_craft({
|
||||
normal = {y = 1},
|
||||
|
Loading…
x
Reference in New Issue
Block a user