2019-09-04 18:44:08 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2020-02-05 07:16:22 -05:00
|
|
|
local ItemStack, math, minetest, nodecore, pairs
|
|
|
|
= ItemStack, math, minetest, nodecore, pairs
|
|
|
|
local math_ceil, math_exp, math_log
|
|
|
|
= math.ceil, math.exp, math.log
|
2019-09-04 18:44:08 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
local convert = {}
|
|
|
|
local charge = {}
|
|
|
|
|
2020-02-20 22:14:29 -05:00
|
|
|
for _, shape in pairs({"mallet", "spade", "hatchet", "pick", "mattock"}) do
|
|
|
|
for _, temper in pairs({"tempered", "annealed"}) do
|
2019-09-04 18:44:08 -04:00
|
|
|
local orig = minetest.registered_items["nc_lode:tool_" .. shape .. "_" .. temper]
|
|
|
|
|
|
|
|
local def = nodecore.underride({
|
|
|
|
description = "Infused " .. orig.description,
|
|
|
|
inventory_image = orig.inventory_image .. "^(" .. modname
|
2020-02-20 22:14:29 -05:00
|
|
|
.. "_base.png^[mask:" .. modname
|
|
|
|
.. "_infuse_mask.png^[mask:nc_lode_tool_" .. shape
|
|
|
|
.. ".png^[opacity:80])",
|
2019-09-04 18:44:08 -04:00
|
|
|
tool_wears_to = orig.name
|
|
|
|
}, orig)
|
|
|
|
def.after_use = nil
|
|
|
|
|
2020-01-21 21:19:30 -05:00
|
|
|
def.groups = nodecore.underride({lux_tool = 1}, orig.groups or {})
|
2019-09-07 21:20:41 -04:00
|
|
|
|
2019-09-04 18:44:08 -04:00
|
|
|
local tc = {}
|
|
|
|
for k, v in pairs(orig.tool_capabilities.opts) do
|
|
|
|
tc[k] = v + 1
|
|
|
|
end
|
2019-09-05 23:17:17 -04:00
|
|
|
tc.uses = 0.5
|
2019-09-04 18:44:08 -04:00
|
|
|
def.tool_capabilities = nodecore.toolcaps(tc)
|
|
|
|
|
|
|
|
def.name = modname .. ":tool_" .. shape .. "_" .. temper
|
|
|
|
minetest.register_tool(def.name, def)
|
|
|
|
|
|
|
|
convert[orig.name] = def.name
|
|
|
|
charge[def.name] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Active ItemStack Modifier overhaul.
AISM's now tick against stacks, including in piles, shelves,
and player inventories, (hopefully) efficiently compared to
the old way with separate ABMs. Item entity support is also
possible, but not necessary yet.
This started out as a bugfix for being able to put a torch inside a
shelf, which didn't make much sense gameplay-wise. It ended up
going quite a bit further.
- Aggregate now gets wet in stack form. Swimming with dry
concrete now has consequences.
- Lux reactions, radiation, and infusion should now behave more
consistently.
- Sponges can now wet or dry in stack form, including inside
containers.
- Torch ignition, quenching, and extinguishing is now more
consistent regardless of context, and torches are now more
dangerous, and can ignite things in more contexts.
2019-10-29 20:03:00 -04:00
|
|
|
local alltools = {}
|
|
|
|
for k in pairs(convert) do alltools[#alltools + 1] = k end
|
|
|
|
for k in pairs(charge) do
|
|
|
|
if not convert[k] then
|
|
|
|
alltools[#alltools + 1] = k
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-27 10:41:03 -05:00
|
|
|
local ratefactor = 40000
|
Active ItemStack Modifier overhaul.
AISM's now tick against stacks, including in piles, shelves,
and player inventories, (hopefully) efficiently compared to
the old way with separate ABMs. Item entity support is also
possible, but not necessary yet.
This started out as a bugfix for being able to put a torch inside a
shelf, which didn't make much sense gameplay-wise. It ended up
going quite a bit further.
- Aggregate now gets wet in stack form. Swimming with dry
concrete now has consequences.
- Lux reactions, radiation, and infusion should now behave more
consistently.
- Sponges can now wet or dry in stack form, including inside
containers.
- Torch ignition, quenching, and extinguishing is now more
consistent regardless of context, and torches are now more
dangerous, and can ignite things in more contexts.
2019-10-29 20:03:00 -04:00
|
|
|
nodecore.register_soaking_aism({
|
2019-09-04 18:44:08 -04:00
|
|
|
label = "Lux Infusion",
|
2020-01-11 08:42:23 -05:00
|
|
|
fieldname = "infuse",
|
2019-09-05 22:48:30 -04:00
|
|
|
interval = 2,
|
|
|
|
chance = 1,
|
Active ItemStack Modifier overhaul.
AISM's now tick against stacks, including in piles, shelves,
and player inventories, (hopefully) efficiently compared to
the old way with separate ABMs. Item entity support is also
possible, but not necessary yet.
This started out as a bugfix for being able to put a torch inside a
shelf, which didn't make much sense gameplay-wise. It ended up
going quite a bit further.
- Aggregate now gets wet in stack form. Swimming with dry
concrete now has consequences.
- Lux reactions, radiation, and infusion should now behave more
consistently.
- Sponges can now wet or dry in stack form, including inside
containers.
- Torch ignition, quenching, and extinguishing is now more
consistent regardless of context, and torches are now more
dangerous, and can ignite things in more contexts.
2019-10-29 20:03:00 -04:00
|
|
|
itemnames = alltools,
|
|
|
|
soakrate = function(stack, aismdata)
|
2019-09-04 18:44:08 -04:00
|
|
|
local name = stack:get_name()
|
2019-09-05 22:48:30 -04:00
|
|
|
if (not charge[name]) and (not convert[name]) then return false end
|
2019-09-05 21:31:16 -04:00
|
|
|
|
Active ItemStack Modifier overhaul.
AISM's now tick against stacks, including in piles, shelves,
and player inventories, (hopefully) efficiently compared to
the old way with separate ABMs. Item entity support is also
possible, but not necessary yet.
This started out as a bugfix for being able to put a torch inside a
shelf, which didn't make much sense gameplay-wise. It ended up
going quite a bit further.
- Aggregate now gets wet in stack form. Swimming with dry
concrete now has consequences.
- Lux reactions, radiation, and infusion should now behave more
consistently.
- Sponges can now wet or dry in stack form, including inside
containers.
- Torch ignition, quenching, and extinguishing is now more
consistent regardless of context, and torches are now more
dangerous, and can ignite things in more contexts.
2019-10-29 20:03:00 -04:00
|
|
|
local pos = aismdata.pos or aismdata.player and aismdata.player:get_pos()
|
2020-02-05 07:16:22 -05:00
|
|
|
return nodecore.lux_soak_rate(pos)
|
2019-09-05 22:48:30 -04:00
|
|
|
end,
|
Active ItemStack Modifier overhaul.
AISM's now tick against stacks, including in piles, shelves,
and player inventories, (hopefully) efficiently compared to
the old way with separate ABMs. Item entity support is also
possible, but not necessary yet.
This started out as a bugfix for being able to put a torch inside a
shelf, which didn't make much sense gameplay-wise. It ended up
going quite a bit further.
- Aggregate now gets wet in stack form. Swimming with dry
concrete now has consequences.
- Lux reactions, radiation, and infusion should now behave more
consistently.
- Sponges can now wet or dry in stack form, including inside
containers.
- Torch ignition, quenching, and extinguishing is now more
consistent regardless of context, and torches are now more
dangerous, and can ignite things in more contexts.
2019-10-29 20:03:00 -04:00
|
|
|
soakcheck = function(data, stack)
|
2019-09-05 22:48:30 -04:00
|
|
|
local name = stack:get_name()
|
2019-12-27 10:41:03 -05:00
|
|
|
if convert[name] and stack:get_wear() < 3277 then
|
2019-09-04 18:44:08 -04:00
|
|
|
stack = ItemStack(convert[name])
|
2019-12-27 10:41:03 -05:00
|
|
|
stack:set_wear(65535)
|
|
|
|
return data.total, stack
|
2019-09-04 18:44:08 -04:00
|
|
|
end
|
2019-12-27 10:41:03 -05:00
|
|
|
if not charge[name] then return data.total, stack end
|
|
|
|
local wear = stack:get_wear()
|
|
|
|
local newear = math_ceil(wear * math_exp(-data.total / ratefactor))
|
|
|
|
if newear == wear then return data.total, stack end
|
|
|
|
local used = math_log(wear / newear) * ratefactor
|
|
|
|
stack:set_wear(newear)
|
|
|
|
return data.total - used, stack
|
2019-09-04 18:44:08 -04:00
|
|
|
end
|
|
|
|
})
|