2019-09-14 20:35:58 -07:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
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 math, minetest, nodecore, pairs, vector
|
|
|
|
= math, minetest, nodecore, pairs, vector
|
2020-03-15 09:02:58 -04:00
|
|
|
local math_ceil, math_log, math_random
|
|
|
|
= math.ceil, math.log, math.random
|
2019-09-14 20:35:58 -07:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-10-06 12:06:36 -04:00
|
|
|
local checkdirs = {
|
|
|
|
{x = 1, y = 0, z = 0},
|
|
|
|
{x = -1, y = 0, z = 0},
|
|
|
|
{x = 0, y = 0, z = 1},
|
|
|
|
{x = 0, y = 0, z = -1},
|
|
|
|
{x = 0, y = 1, z = 0}
|
|
|
|
}
|
2021-07-10 11:09:44 -04:00
|
|
|
minetest.register_abm({
|
2020-06-17 07:09:20 -04:00
|
|
|
label = "torch ignite",
|
2019-10-01 18:30:15 -04:00
|
|
|
interval = 6,
|
|
|
|
chance = 1,
|
2020-03-15 09:02:58 -04:00
|
|
|
nodenames = {"group:torch_lit"},
|
2019-10-01 18:30:15 -04:00
|
|
|
neighbors = {"group:flammable"},
|
|
|
|
action = function(pos)
|
2019-10-06 12:06:36 -04:00
|
|
|
for _, ofst in pairs(checkdirs) do
|
2019-10-01 18:30:15 -04:00
|
|
|
local npos = vector.add(pos, ofst)
|
|
|
|
local nbr = minetest.get_node(npos)
|
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
|
|
|
if minetest.get_item_group(nbr.name, "flammable") > 0
|
|
|
|
and not nodecore.quenched(npos) then
|
2019-10-01 18:30:15 -04:00
|
|
|
nodecore.fire_check_ignite(npos, nbr)
|
|
|
|
end
|
2019-09-14 20:35:58 -07:00
|
|
|
end
|
|
|
|
end
|
2019-10-01 18:30:15 -04:00
|
|
|
})
|
2019-09-14 20:35:58 -07:00
|
|
|
|
2020-03-15 09:02:58 -04:00
|
|
|
local log2 = math_log(2)
|
|
|
|
local function torchlife(expire)
|
|
|
|
local max = nodecore.torch_life_stages
|
|
|
|
if expire <= nodecore.gametime then return max end
|
|
|
|
local life = (expire - nodecore.gametime) / nodecore.torch_life_base
|
|
|
|
if life > 1 then return 1 end
|
|
|
|
local stage = 1 - math_ceil(math_log(life) / log2)
|
|
|
|
if stage < 1 then return 1 end
|
|
|
|
if stage > max then return max end
|
|
|
|
return stage
|
|
|
|
end
|
|
|
|
|
2021-07-10 11:09:44 -04:00
|
|
|
minetest.register_abm({
|
2020-06-17 07:09:20 -04:00
|
|
|
label = "torch snuff",
|
2019-10-01 18:30:15 -04:00
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
2020-03-15 09:02:58 -04:00
|
|
|
nodenames = {"group:torch_lit"},
|
|
|
|
action = function(pos, node)
|
|
|
|
local expire = minetest.get_meta(pos):get_float("expire") or 0
|
|
|
|
if nodecore.quenched(pos) or nodecore.gametime > expire then
|
2019-10-01 19:01:06 -04:00
|
|
|
minetest.remove_node(pos)
|
2019-10-01 18:30:15 -04:00
|
|
|
minetest.add_item(pos, {name = "nc_fire:lump_ash"})
|
2020-04-05 21:22:51 -04:00
|
|
|
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
|
2020-03-15 09:02:58 -04:00
|
|
|
return
|
|
|
|
end
|
|
|
|
local nn = modname .. ":torch_lit_" .. torchlife(expire)
|
|
|
|
if node.name ~= nn then
|
|
|
|
node.name = nn
|
|
|
|
return minetest.swap_node(pos, node)
|
2019-10-01 18:30:15 -04:00
|
|
|
end
|
2019-09-14 21:40:35 -07:00
|
|
|
end
|
2019-10-01 18:30:15 -04:00
|
|
|
})
|
2019-10-01 19:23:34 -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
|
|
|
nodecore.register_aism({
|
2020-06-17 07:09:20 -04:00
|
|
|
label = "torch stack interact",
|
2020-03-15 09:02:58 -04:00
|
|
|
itemnames = {"group:torch_lit"},
|
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
|
|
|
action = function(stack, data)
|
|
|
|
local expire = stack:get_meta():get_float("expire") or 0
|
2019-11-10 08:10:34 -05:00
|
|
|
if expire < nodecore.gametime then
|
2020-04-05 21:22:51 -04:00
|
|
|
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = data.pos})
|
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 "nc_fire:lump_ash"
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos = data.pos
|
|
|
|
local player = data.player
|
2021-02-03 22:02:30 -05:00
|
|
|
local wield
|
|
|
|
if player and data.list == "main"
|
|
|
|
and player:get_wield_index() == data.slot then
|
|
|
|
wield = true
|
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
|
|
|
pos = vector.add(pos, vector.multiply(player:get_look_dir(), 0.5))
|
|
|
|
end
|
|
|
|
|
2019-11-18 22:55:36 -05:00
|
|
|
if nodecore.quenched(pos, data.node and 1 or 0.3) then
|
2020-04-05 21:22:51 -04:00
|
|
|
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
|
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 "nc_fire:lump_ash"
|
|
|
|
end
|
2021-02-03 22:02:30 -05:00
|
|
|
|
|
|
|
if wield and math_random() < 0.1 then nodecore.fire_check_ignite(pos) end
|
2020-03-15 09:02:58 -04:00
|
|
|
|
|
|
|
local nn = modname .. ":torch_lit_" .. torchlife(expire)
|
|
|
|
if stack:get_name() ~= nn then
|
|
|
|
stack:set_name(nn)
|
|
|
|
return stack
|
|
|
|
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
|
|
|
end
|
|
|
|
})
|