ethereal/dirt.lua

141 lines
3.9 KiB
Lua
Raw Normal View History

2015-04-10 17:38:53 +03:00
-- override default dirt (to stop caves cutting away dirt)
2014-11-09 22:17:41 +03:00
minetest.override_item("default:dirt", {is_ground_content = false})
2015-04-10 17:38:53 +03:00
-- green dirt
2014-11-09 22:17:41 +03:00
minetest.register_node("ethereal:green_dirt", {
description = "Green Dirt",
tiles = {
"default_grass.png",
"default_dirt.png",
"default_dirt.png^default_grass_side.png"
},
2014-11-09 22:17:41 +03:00
is_ground_content = false,
2015-07-04 14:22:39 +03:00
groups = {crumbly = 3, soil = 1, ethereal_grass = 1},
2014-11-09 22:17:41 +03:00
drop = "default:dirt",
sounds = default.node_sound_dirt_defaults()
})
2015-04-10 17:38:53 +03:00
-- dry dirt
2014-11-09 22:17:41 +03:00
minetest.register_node("ethereal:dry_dirt", {
description = "Dried Dirt",
tiles = {"ethereal_dry_dirt.png"},
is_ground_content = false,
2015-07-04 14:22:39 +03:00
groups = {crumbly = 3},
2014-11-09 22:17:41 +03:00
sounds = default.node_sound_dirt_defaults()
})
minetest.register_craft({
type = "cooking",
output = "ethereal:dry_dirt",
recipe = "default:dirt",
cooktime = 3,
})
local dirt = {}
dirt.type = {
2015-07-04 14:22:39 +03:00
{"Bamboo"}, {"Jungle"}, {"Grove"}, {"Prairie"}, {"Cold"},
{"Crystal"}, {"Mushroom"}, {"Fiery"}, {"Gray"},
2014-11-09 22:17:41 +03:00
}
for _, row in ipairs(dirt.type) do
local desc = row[1]
local name = desc:lower()
minetest.register_node("ethereal:"..name.."_dirt", {
description = desc.." Dirt",
tiles = {
"ethereal_grass_"..name.."_top.png",
"default_dirt.png",
"default_dirt.png^ethereal_grass_"..name.."_side.png"
},
2014-11-09 22:17:41 +03:00
is_ground_content = false,
2015-07-04 14:22:39 +03:00
groups = {crumbly = 3, soil = 1, ethereal_grass = 1},
2014-11-09 22:17:41 +03:00
drop = "default:dirt",
sounds = default.node_sound_dirt_defaults()
})
end
-- Compatibility with old maps
minetest.register_alias("ethereal:crystal_topped_dirt", "ethereal:crystal_dirt")
minetest.register_alias("ethereal:fiery_dirt_top", "ethereal:fiery_dirt")
minetest.register_alias("ethereal:gray_dirt_top", "ethereal:gray_dirt")
minetest.register_alias("ethereal:green_dirt_top", "ethereal:green_dirt")
2015-04-10 17:38:53 +03:00
-- check surrounding grass and change dirt to same colour (by Sokomine)
2014-11-09 22:17:41 +03:00
minetest.register_abm({
nodenames = {"default:dirt_with_grass"},
interval = 5,
2015-04-10 17:38:53 +03:00
chance = 2,
2015-11-07 23:50:50 +03:00
catch_up = false,
2014-11-09 22:17:41 +03:00
action = function(pos, node)
local count_grasses = {}
local curr_max = 0
2015-05-12 12:11:32 +03:00
local curr_type = "ethereal:green_dirt" -- fallback
2015-04-10 17:38:53 +03:00
local positions = minetest.find_nodes_in_area(
2015-07-04 14:22:39 +03:00
{x = (pos.x - 2), y = (pos.y - 1), z = (pos.z - 2)},
{x = (pos.x + 2), y = (pos.y + 1), z = (pos.z + 2)},
2015-04-10 17:38:53 +03:00
"group:ethereal_grass")
2015-05-12 12:11:32 +03:00
local n
2015-04-10 17:38:53 +03:00
-- count new grass nodes
2014-11-09 22:17:41 +03:00
for _,p in ipairs(positions) do
2015-05-12 12:11:32 +03:00
n = minetest.get_node_or_nil(p)
2015-04-10 17:38:53 +03:00
if n and n.name then
2015-05-12 12:11:32 +03:00
count_grasses[n.name] = (count_grasses[n.name] or 0) + 1
2015-04-10 17:38:53 +03:00
-- we found a grass type with more than current max
if count_grasses[n.name] > curr_max then
curr_max = count_grasses[n.name]
2014-11-09 22:17:41 +03:00
curr_type = n.name
end
end
end
2015-04-10 17:38:53 +03:00
minetest.set_node(pos, {name = curr_type})
2015-07-04 14:22:39 +03:00
end
2014-11-09 22:17:41 +03:00
})
2015-04-10 17:38:53 +03:00
-- if grass devoid of light, change to dirt
2014-11-09 22:17:41 +03:00
minetest.register_abm({
nodenames = {"group:ethereal_grass"},
2015-04-10 17:38:53 +03:00
interval = 2,
2014-11-09 22:17:41 +03:00
chance = 20,
2015-11-07 23:50:50 +03:00
catch_up = false,
2014-11-09 22:17:41 +03:00
action = function(pos, node)
2015-07-04 14:22:39 +03:00
local name = minetest.get_node({x = pos.x, y =pos.y + 1, z = pos.z}).name
2014-11-09 22:17:41 +03:00
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef
2015-04-10 17:38:53 +03:00
and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
and nodedef.liquidtype == "none") then
2014-11-09 22:17:41 +03:00
minetest.set_node(pos, {name = "default:dirt"})
end
end
})
-- If Baked Clay mod not active, make Red and Orange nodes
if not minetest.get_modpath("bakedclay") then
minetest.register_node(":bakedclay:red", {
description = "Red Baked Clay",
tiles = {"baked_clay_red.png"},
2015-07-04 14:22:39 +03:00
groups = {cracky = 3},
2014-11-09 22:17:41 +03:00
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
2014-11-09 22:17:41 +03:00
minetest.register_node(":bakedclay:orange", {
description = "Orange Baked Clay",
tiles = {"baked_clay_orange.png"},
2015-07-04 14:22:39 +03:00
groups = {cracky = 3},
2014-11-09 22:17:41 +03:00
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node(":bakedclay:grey", {
description = "Grey Baked Clay",
tiles = {"baked_clay_grey.png"},
groups = {cracky = 3},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
2015-07-04 14:22:39 +03:00
end