2019-09-14 20:35:58 -07:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-11-10 08:10:34 -05:00
|
|
|
local ItemStack, minetest, nodecore, pairs, setmetatable, vector
|
|
|
|
= ItemStack, minetest, nodecore, pairs, setmetatable, vector
|
2019-09-14 20:35:58 -07:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-10-01 19:01:06 -04:00
|
|
|
local function islit(stack)
|
2019-10-01 21:30:20 -04:00
|
|
|
return stack and stack:get_name() == modname .. ":torch_lit"
|
2019-10-01 19:01:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
local function snuffinv(player, inv, i)
|
|
|
|
minetest.sound_play("nc_fire_snuff", {object = player, gain = 0.5})
|
|
|
|
inv:set_stack("main", i, "nc_fire:lump_ash")
|
|
|
|
end
|
|
|
|
|
2019-10-01 21:30:20 -04:00
|
|
|
local function wieldlight(pos)
|
|
|
|
local cur = minetest.get_node(pos).name
|
|
|
|
if cur ~= "air" and cur ~= modname .. ":wield_light" then return end
|
|
|
|
minetest.set_node(pos, {name = modname .. ":wield_light"})
|
|
|
|
return minetest.get_node_timer(pos):start(0.3)
|
|
|
|
end
|
|
|
|
|
2019-10-01 19:01:06 -04:00
|
|
|
local wltimers = {}
|
2019-10-01 19:23:34 -04:00
|
|
|
local ambtimers = {}
|
2019-11-10 08:10:34 -05:00
|
|
|
minetest.register_globalstep(function()
|
|
|
|
local now = nodecore.gametime
|
2019-10-01 19:01:06 -04:00
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
local inv = player:get_inventory()
|
|
|
|
local ppos = player:get_pos()
|
|
|
|
|
|
|
|
-- Snuff all torches if doused in water.
|
|
|
|
local hpos = vector.add(ppos, {x = 0, y = 1, z = 0})
|
|
|
|
local head = minetest.get_node(hpos).name
|
2019-10-05 17:49:16 -04:00
|
|
|
if minetest.get_item_group(head, "water") > 0 then
|
2019-10-01 19:01:06 -04:00
|
|
|
for i = 1, inv:get_size("main") do
|
|
|
|
local stack = inv:get_stack("main", i)
|
|
|
|
if islit(stack) then snuffinv(player, inv, i) 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
|
|
|
elseif islit(player:get_wielded_item()) then
|
|
|
|
-- Wield light
|
|
|
|
local name = player:get_player_name()
|
|
|
|
local t = wltimers[name] or 0
|
|
|
|
if t <= now then
|
|
|
|
wltimers[name] = now + 0.2
|
|
|
|
wieldlight(hpos)
|
2019-09-14 20:35:58 -07:00
|
|
|
end
|
2019-10-01 19:01:06 -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
|
|
|
-- Wield ambiance
|
|
|
|
t = ambtimers[name] or 0
|
|
|
|
if t <= now then
|
|
|
|
ambtimers[name] = now + 1
|
|
|
|
minetest.sound_play("nc_fire_flamy",
|
|
|
|
{object = player, gain = 0.1})
|
2019-09-14 20:35:58 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-10-01 18:30:15 -04:00
|
|
|
end)
|
2019-10-01 21:30:20 -04:00
|
|
|
|
|
|
|
-- Apply wield light to entities as well.
|
|
|
|
local function entlight(self, dtime, ...)
|
|
|
|
local stack = ItemStack(self.node and self.node.name or self.itemstring or "")
|
|
|
|
if not islit(stack) then return ... end
|
|
|
|
local wltime = (self.wltime or 0) - dtime
|
|
|
|
if wltime <= 0 then
|
|
|
|
wltime = 0.2
|
|
|
|
wieldlight(self.object:get_pos())
|
|
|
|
end
|
|
|
|
self.wltime = wltime
|
|
|
|
return ...
|
|
|
|
end
|
|
|
|
for _, name in pairs({"item", "falling_node"}) do
|
|
|
|
local def = minetest.registered_entities["__builtin:" .. name]
|
|
|
|
local ndef = {
|
|
|
|
on_step = function(self, dtime, ...)
|
|
|
|
return entlight(self, dtime, def.on_step(self, dtime, ...))
|
|
|
|
end
|
|
|
|
}
|
|
|
|
setmetatable(ndef, def)
|
|
|
|
minetest.register_entity(":__builtin:" .. name, ndef)
|
|
|
|
end
|