Artificial stone hardening process

Stone is hardened by creating an elecric field via the Peltier
effect that causes internal crystals to align.  Or something like
that.

Stone hardens over time when touching both lava and water.
All stratafiable stone types (lode sign, lode ore, lux ore) are
affected.
This commit is contained in:
Aaron Suen 2020-06-04 08:09:30 -04:00
parent 1b646d3f63
commit 23527e264b
5 changed files with 59 additions and 4 deletions

View File

@ -55,7 +55,7 @@ for i = 1, nodecore.hard_stone_strata do
drop_in_place = modname .. ((i > 1)
and (":stone_" .. (i - 1)) or ":stone"),
groups = {
stone = i,
stone = i + 1,
lodey = 1,
cracky = i + 2,
hard_stone = i
@ -68,7 +68,7 @@ for i = 1, nodecore.hard_stone_strata do
.. modname .. "_mask_ore.png)"},
drop_in_place = modname .. ":cobble",
groups = {
stone = i,
stone = i + 1,
lodey = 1,
cracky = i + 2,
hard_stone = i

View File

@ -70,7 +70,7 @@ for i = 1, nodecore.hard_stone_strata do
rock = i,
lux_emit = 1,
cracky = i + 2,
stone = i,
stone = i + 1,
hard_stone = i
},
light_source = 1,

View File

@ -0,0 +1,54 @@
-- LUALOCALS < ---------------------------------------------------------
local math, minetest, nodecore, pairs
= math, minetest, nodecore, pairs
local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
local harden_to = {}
local harden_idx = {}
minetest.after(0, function()
for _, v in pairs(minetest.registered_nodes) do
if v.strata then
for i, n in pairs(v.strata) do
harden_to[n] = v.strata[i + 1]
harden_idx[n] = i
end
end
end
end)
local queue = {}
local function process(pos)
local node = minetest.get_node(pos)
node.name = harden_to[node.name]
if not node.name then return end
local water = #nodecore.find_nodes_around(pos, "group:water")
local lava = #nodecore.find_nodes_around(pos, "group:lava")
if water < 1 or lava < 1 then return end
local chance = harden_idx[node.name] - (water > lava and water or lava) / 8
if (chance > 0) and (math_random() > 0.5 ^ chance) then return end
return nodecore.set_loud(pos, node)
end
minetest.register_globalstep(function()
for _, p in pairs(queue) do process(p) end
queue = {}
end)
nodecore.register_limited_abm({
nodenames = {"group:lava"},
neighbors = {"group:stone"},
interval = 10,
chance = 10,
action = function(pos)
if not minetest.find_node_near(pos, 2, "group:water") then return end
for _, p in pairs(nodecore.find_nodes_around(pos, "group:stone")) do
queue[minetest.hash_node_position(p)] = p
end
end
})

View File

@ -8,3 +8,4 @@ nodecore.amcoremod()
include("chip")
include("tools")
include("bricks")
include("harden")

View File

@ -89,7 +89,7 @@ for i = 1, nodecore.hard_stone_strata do
tiles = {nodecore.hard_stone_tile(i)},
silktouch = false,
groups = {
stone = i,
stone = i + 1,
rock = i,
cracky = i + 2,
hard_stone = i