2021-03-14 10:26:46 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, minetest, nodecore, pairs, string, vector
|
|
|
|
= math, minetest, nodecore, pairs, string, vector
|
|
|
|
local math_pow, math_random, string_format
|
|
|
|
= math.pow, math.random, string.format
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local lavaname = "nc_terrain:lava_source"
|
|
|
|
local stonename = "nc_terrain:stone"
|
|
|
|
|
2021-07-10 11:09:44 -04:00
|
|
|
minetest.register_abm({
|
2021-03-23 20:27:35 -04:00
|
|
|
label = "stone melting",
|
|
|
|
nodenames = {stonename},
|
|
|
|
neighbors = {lavaname},
|
|
|
|
neighbors_invert = true,
|
2021-03-14 10:26:46 -04:00
|
|
|
interval = 10,
|
|
|
|
chance = 125,
|
|
|
|
action = function(pos)
|
2021-03-23 20:27:35 -04:00
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if node.name ~= stonename then return end
|
|
|
|
|
|
|
|
local lavas = 0
|
|
|
|
for _, dir in pairs(nodecore.dirs()) do
|
2021-04-23 06:58:05 -04:00
|
|
|
if minetest.get_node(vector.add(pos, dir)).name == lavaname then
|
2021-03-23 20:27:35 -04:00
|
|
|
lavas = lavas + 1
|
|
|
|
end
|
2021-03-14 10:26:46 -04:00
|
|
|
end
|
2021-06-20 12:49:49 -04:00
|
|
|
if (lavas < 4) or (math_random() > math_pow(1.25, lavas - 4) / 3) then return end
|
2021-03-23 20:27:35 -04:00
|
|
|
|
2021-12-11 21:26:18 -05:00
|
|
|
nodecore.log("info", string_format("%s melted to %s at %s (%d sources)",
|
2021-03-23 20:27:35 -04:00
|
|
|
stonename, lavaname, minetest.pos_to_string(pos), lavas))
|
2021-12-12 00:04:37 -05:00
|
|
|
nodecore.set_loud(pos, {name = lavaname})
|
|
|
|
return nodecore.witness(pos, "stone melted")
|
2021-03-14 10:26:46 -04:00
|
|
|
end
|
|
|
|
})
|