nodecore-cd2025/mods/nc_api/util_toolcaps.lua
Aaron Suen df19716624 Make everything diggable by hand.
This should keep players from being able to trap
themselves permanently by burying or sealing
themselves inside a room with no tools, in theory.

Adjust silk touch logic to prevent presence of dig times
by hand from tripping it.

This may affect game balance of things like not being
able to punch trees in the early game, but since dig
times by hand are so very long, hopefully the effect
will be small.

Item drops are left as-is for now; it just takes a LOT
of patience to dig something without the right tool.
2019-12-29 11:51:25 -05:00

41 lines
912 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local math, nodecore, pairs
= math, nodecore, pairs
local math_pow
= math.pow
-- LUALOCALS > ---------------------------------------------------------
local basetimes = {
cracky = 3,
thumpy = 2,
choppy = 2,
crumbly = 0.5,
snappy = 0.4,
}
nodecore.tool_basetimes = basetimes
for k, v in pairs(basetimes) do
basetimes[k] = v / nodecore.rate_adjustment("speed", "tool", k)
end
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, lv do
local tt = math_pow(0.5, lv - n) * bt
if tt < 0.25 then tt = 0.25 end
times[n] = tt
end
gcaps[gn] = {
times = times,
uses = 5 * math_pow(3, lv) * opts.uses
}
end
end
return {groupcaps = gcaps, opts = opts}
end