2018-05-23 10:32:06 +02:00
|
|
|
-- internationalization boilerplate
|
|
|
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
local S, NS = dofile(MP.."/intllib.lua")
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
minetest.register_node("df_mapitems:cave_coral_3", {
|
2018-05-23 10:32:06 +02:00
|
|
|
description = S("Cave Coral"),
|
2018-12-31 19:46:27 +01:00
|
|
|
_doc_items_longdesc = df_mapitems.doc.cave_coral_desc,
|
|
|
|
_doc_items_usagehelp = df_mapitems.doc.cave_coral_usage,
|
2018-05-23 10:32:06 +02:00
|
|
|
tiles = {"dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral.png"},
|
|
|
|
is_ground_content = true,
|
|
|
|
drop = "default:coral_skeleton",
|
|
|
|
light_source = 3,
|
|
|
|
groups = {cracky = 3, dfcaverns_cave_coral = 1},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
})
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
minetest.register_node("df_mapitems:cave_coral_2", {
|
2018-05-23 10:32:06 +02:00
|
|
|
description = S("Cave Coral"),
|
2018-12-31 19:46:27 +01:00
|
|
|
_doc_items_longdesc = df_mapitems.doc.cave_coral_desc,
|
|
|
|
_doc_items_usagehelp = df_mapitems.doc.cave_coral_usage,
|
2018-05-23 10:32:06 +02:00
|
|
|
tiles = {"dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral.png"},
|
|
|
|
is_ground_content = true,
|
|
|
|
drop = "default:coral_skeleton",
|
|
|
|
light_source = 2,
|
|
|
|
groups = {cracky = 3, dfcaverns_cave_coral = 1},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
})
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
minetest.register_node("df_mapitems:cave_coral_1", {
|
2018-05-23 10:32:06 +02:00
|
|
|
description = S("Cave Coral"),
|
2018-12-31 19:46:27 +01:00
|
|
|
_doc_items_longdesc = df_mapitems.doc.cave_coral_desc,
|
|
|
|
_doc_items_usagehelp = df_mapitems.doc.cave_coral_usage,
|
2018-05-23 10:32:06 +02:00
|
|
|
tiles = {"dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral_end.png", "dfcaverns_cave_coral.png"},
|
|
|
|
is_ground_content = true,
|
|
|
|
drop = "default:coral_skeleton",
|
|
|
|
light_source = 1,
|
|
|
|
groups = {cracky = 3, dfcaverns_cave_coral = 1},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
})
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
local coral_names = {"df_mapitems:cave_coral_1", "df_mapitems:cave_coral_2", "df_mapitems:cave_coral_3"}
|
2018-05-23 10:32:06 +02:00
|
|
|
minetest.register_abm{
|
2018-12-31 19:46:27 +01:00
|
|
|
label = "df_mapitems:shifting_coral",
|
2018-05-23 10:32:06 +02:00
|
|
|
nodenames = {"group:dfcaverns_cave_coral"},
|
|
|
|
interval = 2,
|
|
|
|
chance = 10,
|
|
|
|
action = function(pos)
|
|
|
|
minetest.swap_node(pos, {name=coral_names[math.random(1,3)]})
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
local c_coral_1 = minetest.get_content_id("df_mapitems:cave_coral_1")
|
|
|
|
local c_coral_2 = minetest.get_content_id("df_mapitems:cave_coral_2")
|
|
|
|
local c_coral_3 = minetest.get_content_id("df_mapitems:cave_coral_3")
|
2018-05-23 10:32:06 +02:00
|
|
|
local c_coral_skeleton = minetest.get_content_id("default:coral_skeleton")
|
|
|
|
local c_dirt = minetest.get_content_id("default:dirt")
|
|
|
|
local c_stone = minetest.get_content_id("default:stone")
|
2018-11-17 20:42:36 +01:00
|
|
|
local c_water = minetest.get_content_id("default:water_source")
|
2018-05-23 10:32:06 +02:00
|
|
|
|
|
|
|
local corals = {c_coral_1, c_coral_2, c_coral_3}
|
|
|
|
local get_coral = function()
|
|
|
|
return corals[math.random(1,3)]
|
|
|
|
end
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
df_mapitems.spawn_cave_coral = function(area, data, vi, iterations)
|
2018-05-23 10:32:06 +02:00
|
|
|
local run = math.random(2,4)
|
|
|
|
local index = vi
|
|
|
|
local zstride = area.zstride
|
|
|
|
local ystride = area.ystride
|
|
|
|
while run > 0 do
|
|
|
|
if math.random() > 0.95 or data[index] == c_stone or not area:containsi(index) then return end
|
|
|
|
data[index] = get_coral()
|
|
|
|
if iterations > 2 then
|
|
|
|
data[index + 1] = get_coral()
|
|
|
|
data[index - 1] = get_coral()
|
|
|
|
data[index + zstride] = get_coral()
|
|
|
|
data[index - zstride] = get_coral()
|
|
|
|
end
|
|
|
|
if iterations > 3 then
|
|
|
|
data[index + 2] = get_coral()
|
|
|
|
data[index - 2] = get_coral()
|
|
|
|
data[index + zstride * 2] = get_coral()
|
|
|
|
data[index - zstride * 2] = get_coral()
|
|
|
|
data[index + 1 + zstride] = get_coral()
|
|
|
|
data[index - 1 + zstride] = get_coral()
|
|
|
|
data[index + 1 - zstride] = get_coral()
|
|
|
|
data[index - 1 - zstride] = get_coral()
|
|
|
|
end
|
2018-12-31 19:46:27 +01:00
|
|
|
index = index + ystride
|
2018-05-23 10:32:06 +02:00
|
|
|
run = run - 1
|
|
|
|
end
|
|
|
|
|
|
|
|
local newiterations = iterations - 1
|
|
|
|
if newiterations == 0 then return end
|
|
|
|
|
|
|
|
if math.random() > 0.5 then
|
2018-12-31 19:46:27 +01:00
|
|
|
df_mapitems.spawn_cave_coral(area, data, index + 1 - ystride, newiterations)
|
|
|
|
df_mapitems.spawn_cave_coral(area, data, index - 1 - ystride, newiterations)
|
2018-05-23 10:32:06 +02:00
|
|
|
else
|
2018-12-31 19:46:27 +01:00
|
|
|
df_mapitems.spawn_cave_coral(area, data, index + zstride - ystride, newiterations)
|
|
|
|
df_mapitems.spawn_cave_coral(area, data, index - zstride - ystride, newiterations)
|
2018-05-23 10:32:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-31 19:46:27 +01:00
|
|
|
df_mapitems.spawn_coral_pile = function(area, data, vi, radius)
|
2018-05-23 10:32:06 +02:00
|
|
|
local pos = area:position(vi)
|
|
|
|
for li in area:iterp(vector.add(pos, -radius), vector.add(pos, radius)) do
|
|
|
|
local adjacent = li + area.ystride
|
|
|
|
local node_type = data[li]
|
2018-12-31 19:46:27 +01:00
|
|
|
if math.random() < 0.2 and not mapgen_helper.buildable_to(node_type) and data[adjacent] == c_water then
|
2018-05-23 10:32:06 +02:00
|
|
|
data[adjacent] = c_coral_skeleton
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|