2019-10-13 11:37:36 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, minetest, nodecore, pairs
|
|
|
|
= math, minetest, nodecore, pairs
|
2019-10-14 19:52:19 -04:00
|
|
|
local math_exp, math_log
|
|
|
|
= math.exp, math.log
|
2019-10-13 11:37:36 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
local hand = minetest.registered_items[""]
|
|
|
|
local irradiated = modname .. ":irradiated"
|
|
|
|
minetest.register_craftitem(irradiated, {
|
|
|
|
description = "Burn",
|
|
|
|
stack_max = 1,
|
2019-12-31 11:06:35 -05:00
|
|
|
inventory_image = "[combine:1x1",
|
|
|
|
hotbar_type = "burn",
|
2019-10-13 11:37:36 -04:00
|
|
|
wield_image = hand.wield_image,
|
|
|
|
wield_scale = hand.wield_scale,
|
|
|
|
on_drop = function(stack) return stack end,
|
|
|
|
on_place = function(stack) return stack end,
|
|
|
|
virtual_item = true
|
|
|
|
})
|
|
|
|
|
|
|
|
nodecore.register_healthfx({
|
|
|
|
item = irradiated,
|
2019-10-13 12:57:57 -04:00
|
|
|
getqty = function(player)
|
|
|
|
return player:get_meta():get_float("rad")
|
2019-10-13 11:37:36 -04:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
local luxaccum = {}
|
|
|
|
|
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 function rademit(pos, emit)
|
2019-10-13 11:37:36 -04:00
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local pp = player:get_pos()
|
|
|
|
pp.y = pp.y + 1
|
|
|
|
local dx = pp.x - pos.x
|
|
|
|
dx = dx * dx
|
|
|
|
local dy = pp.y - pos.y
|
|
|
|
dy = dy * dy
|
|
|
|
local dz = pp.z - pos.z
|
|
|
|
dz = dz * dz
|
2019-10-14 06:11:50 -04:00
|
|
|
local dsqr = (dx + dy + dz)
|
|
|
|
if dsqr > (32 * 32) then return end
|
|
|
|
if dsqr < 1 then
|
|
|
|
dsqr = 1
|
|
|
|
else
|
|
|
|
for pt in minetest.raycast(pos, pp, false, true) do
|
2019-10-14 19:52:19 -04:00
|
|
|
local pn = minetest.get_node(pt.under)
|
|
|
|
local def = minetest.registered_items[pn.name] or {groups = {}}
|
|
|
|
if def.groups.water then
|
|
|
|
dsqr = dsqr * 8
|
|
|
|
elseif pn.name ~= "air" and not def.groups.lux_emit then
|
|
|
|
dsqr = dsqr * 2
|
2019-10-14 06:11:50 -04:00
|
|
|
end
|
2019-10-14 06:19:45 -04:00
|
|
|
if dsqr > (32 * 32) then return end
|
2019-10-14 06:11:50 -04:00
|
|
|
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
|
|
|
luxaccum[pname] = (luxaccum[pname] or 0) + (math_log(emit) + 1) / dsqr
|
2019-10-13 11:37:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
nodecore.register_limited_abm({
|
|
|
|
label = "Lux Irradiate",
|
|
|
|
interval = 1,
|
|
|
|
chance = 2,
|
|
|
|
nodenames = {"group:lux_emit"},
|
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(pos, node)
|
|
|
|
local def = minetest.registered_items[node.name]
|
|
|
|
local emit = def and def.groups and def.groups.lux_emit or 1
|
|
|
|
if emit then return rademit(pos, emit) end
|
|
|
|
end
|
2019-10-13 11:37:36 -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({
|
2019-10-13 11:37:36 -04:00
|
|
|
label = "Lux Stack Irradiate",
|
|
|
|
interval = 1,
|
|
|
|
chance = 2,
|
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 = {"group:lux_emit"},
|
|
|
|
action = function(stack, data)
|
2019-10-13 11:37:36 -04:00
|
|
|
local def = minetest.registered_items[stack:get_name()]
|
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 emit = def and def.groups and def.groups.lux_emit
|
|
|
|
or def and def.groups and def.groups.lux_tool
|
|
|
|
and def.groups.lux_tool * 0.1
|
|
|
|
if emit then return rademit(data.pos, emit) end
|
2019-10-13 11:37:36 -04:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
local function luxradpump()
|
|
|
|
minetest.after(1, luxradpump)
|
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
|
|
|
local meta = player:get_meta()
|
|
|
|
local rad = meta:get_float("rad") or 0
|
|
|
|
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local accum = luxaccum[pname] or 0
|
|
|
|
luxaccum[pname] = 0
|
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
|
|
|
|
2019-10-14 19:52:19 -04:00
|
|
|
local prop = math_exp(-accum / 10000)
|
2019-10-13 11:37:36 -04:00
|
|
|
rad = rad * prop + (1 - prop)
|
|
|
|
|
2019-10-14 19:52:19 -04:00
|
|
|
local redux = 0.1
|
2019-10-13 11:37:36 -04:00
|
|
|
local pos = player:get_pos()
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local def = minetest.registered_items[node.name]
|
|
|
|
if def and def.groups and def.groups.water then
|
2019-10-14 19:52:19 -04:00
|
|
|
redux = redux + 50
|
2019-10-13 11:37:36 -04:00
|
|
|
end
|
|
|
|
pos.y = pos.y + 1
|
|
|
|
node = minetest.get_node(pos)
|
|
|
|
def = minetest.registered_items[node.name]
|
|
|
|
if def and def.groups and def.groups.water then
|
2019-10-14 19:52:19 -04:00
|
|
|
redux = redux + 500
|
2019-10-13 11:37:36 -04:00
|
|
|
end
|
2019-10-14 19:52:19 -04:00
|
|
|
prop = math_exp(-redux / 10000)
|
2019-10-13 11:37:36 -04:00
|
|
|
rad = rad * prop
|
|
|
|
|
|
|
|
meta:set_float("rad", rad)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
luxradpump()
|