2019-09-04 18:44:08 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-09-05 21:31:16 -04:00
|
|
|
local ItemStack, math, minetest, nodecore, pairs, vector
|
|
|
|
= ItemStack, math, minetest, nodecore, pairs, vector
|
2019-09-05 22:48:30 -04:00
|
|
|
local math_floor, math_pow
|
|
|
|
= math.floor, math.pow
|
2019-09-04 18:44:08 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
local convert = {}
|
|
|
|
local charge = {}
|
|
|
|
|
|
|
|
for _, shape in pairs({'mallet', 'spade', 'hatchet', 'pick', 'mattock'}) do
|
|
|
|
for _, temper in pairs({'tempered', 'annealed'}) do
|
|
|
|
local orig = minetest.registered_items["nc_lode:tool_" .. shape .. "_" .. temper]
|
|
|
|
|
|
|
|
local def = nodecore.underride({
|
|
|
|
description = "Infused " .. orig.description,
|
|
|
|
inventory_image = orig.inventory_image .. "^(" .. modname
|
|
|
|
.. "_base.png^[mask:nc_lode_tool_" .. shape .. ".png^[opacity:64])",
|
|
|
|
tool_wears_to = orig.name
|
|
|
|
}, orig)
|
|
|
|
def.after_use = nil
|
|
|
|
|
2019-09-07 21:20:41 -04:00
|
|
|
def.groups = def.groups or {}
|
|
|
|
def.groups.lux_tool = 1
|
|
|
|
|
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
|
|
|
|
|
2019-09-05 21:14:24 -04:00
|
|
|
local function isfluid(pos)
|
|
|
|
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
|
|
|
return def and def.groups and def.groups.lux_fluid
|
|
|
|
end
|
2019-09-04 18:44:08 -04:00
|
|
|
local indirs = {}
|
|
|
|
for _, v in pairs(nodecore.dirs()) do
|
2019-09-05 21:14:24 -04:00
|
|
|
if v.y == 0 then
|
2019-09-04 18:44:08 -04:00
|
|
|
indirs[#indirs + 1] = v
|
|
|
|
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
|
|
|
|
|
|
|
|
nodecore.register_soaking_aism({
|
2019-09-04 18:44:08 -04:00
|
|
|
label = "Lux Infusion",
|
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()
|
|
|
|
|
2019-09-05 21:14:24 -04:00
|
|
|
local above = vector.add(pos, {x = 0, y = 1, z = 0})
|
2019-09-05 22:48:30 -04:00
|
|
|
if not isfluid(above) then return false end
|
2019-09-05 21:14:24 -04:00
|
|
|
local qty = 1
|
2019-09-04 18:44:08 -04:00
|
|
|
for _, v in pairs(indirs) do
|
2019-09-05 21:14:24 -04:00
|
|
|
if isfluid(vector.add(pos, v)) then qty = qty + 1 end
|
2019-09-04 18:44:08 -04:00
|
|
|
end
|
2019-09-05 21:31:16 -04:00
|
|
|
|
|
|
|
local dist = nodecore.scan_flood(above, 14, function(p, d)
|
|
|
|
if p.dir and p.dir.y < 0 then return false end
|
|
|
|
local nn = minetest.get_node(p).name
|
|
|
|
if nn == modname .. ":flux_source" then return d end
|
|
|
|
if nn ~= modname .. ":flux_flowing" then return false end
|
|
|
|
end)
|
2019-09-05 22:48:30 -04:00
|
|
|
if not dist then return false end
|
2019-09-05 21:31:16 -04:00
|
|
|
|
2019-09-05 22:48:30 -04:00
|
|
|
return qty * 20 / math_pow(2, dist / 2)
|
|
|
|
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()
|
|
|
|
local dw = math_floor(data.total)
|
2019-09-04 18:44:08 -04:00
|
|
|
if charge[name] then
|
2019-09-05 22:48:30 -04:00
|
|
|
stack:add_wear(-dw)
|
2019-09-04 18:44:08 -04:00
|
|
|
elseif convert[name] and stack:get_wear() < 3277 then
|
|
|
|
stack = ItemStack(convert[name])
|
2019-09-05 22:48:30 -04:00
|
|
|
stack:set_wear(65535 - dw)
|
2019-09-04 18:44:08 -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
|
|
|
return data.total - dw, stack
|
2019-09-04 18:44:08 -04:00
|
|
|
end
|
|
|
|
})
|