Add decorations for crops. Simplify deco code.
parent
a35525f8f3
commit
35d3ee9f47
144
deco.lua
144
deco.lua
|
@ -5,6 +5,9 @@
|
||||||
-- The main decoration handler, through the game's decoration manager.
|
-- The main decoration handler, through the game's decoration manager.
|
||||||
|
|
||||||
|
|
||||||
|
-- A list of all schematics, for re-use.
|
||||||
|
loud_walking.schematics = {}
|
||||||
|
|
||||||
function table.contains_substring(t, s)
|
function table.contains_substring(t, s)
|
||||||
if type(s) ~= "string" then
|
if type(s) ~= "string" then
|
||||||
return nil
|
return nil
|
||||||
|
@ -24,15 +27,43 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- Copy all the decorations except the ones I don't like.
|
-- Copy all the decorations except the ones I don't like.
|
||||||
-- This is currently used to remove the default trees.
|
loud_walking.decorations = {}
|
||||||
local bad_deco = {"apple_tree", "pine_tree", "jungle_tree", "acacia_tree", "aspen_tree", }
|
local bad_deco = {}
|
||||||
local decos = {}
|
for _, i in pairs({"apple_tree", "pine_tree", "jungle_tree", "acacia_tree", "aspen_tree", }) do
|
||||||
for id, deco_table in pairs(minetest.registered_decorations) do
|
bad_deco[i] = true
|
||||||
if type(deco_table.schematic) ~= "string" or not table.contains_substring(bad_deco, deco_table.schematic) then
|
end
|
||||||
table.insert(decos, deco_table)
|
|
||||||
|
do
|
||||||
|
for _, odeco in pairs(minetest.registered_decorations) do
|
||||||
|
if not bad_deco[odeco.schematic] then
|
||||||
|
local deco = {}
|
||||||
|
if odeco.biomes then
|
||||||
|
deco.biomes = {}
|
||||||
|
for _, b in pairs(odeco.biomes) do
|
||||||
|
deco.biomes[b] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
deco.deco_type = odeco.deco_type
|
||||||
|
deco.decoration = odeco.decoration
|
||||||
|
deco.schematic = odeco.schematic
|
||||||
|
deco.fill_ratio = odeco.fill_ratio
|
||||||
|
|
||||||
|
if odeco.noise_params then
|
||||||
|
deco.fill_ratio = (odeco.noise_params.scale + odeco.noise_params.offset)
|
||||||
|
end
|
||||||
|
|
||||||
|
local nod = minetest.registered_nodes[deco.decoration]
|
||||||
|
if nod and nod.groups and nod.groups.flower then
|
||||||
|
deco.flower = true
|
||||||
|
end
|
||||||
|
|
||||||
|
loud_walking.decorations[#loud_walking.decorations+1] = deco
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.clear_registered_decorations()
|
||||||
|
|
||||||
-- Create and initialize a table for a schematic.
|
-- Create and initialize a table for a schematic.
|
||||||
function loud_walking.schematic_array(width, height, depth)
|
function loud_walking.schematic_array(width, height, depth)
|
||||||
|
@ -57,19 +88,96 @@ function loud_walking.schematic_array(width, height, depth)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Clear all decorations, so I can place the new trees.
|
|
||||||
minetest.clear_registered_decorations()
|
|
||||||
|
|
||||||
-- A list of all schematics, for re-use.
|
|
||||||
loud_walking.schematics = {}
|
|
||||||
|
|
||||||
|
|
||||||
dofile(loud_walking.path.."/deco_trees.lua")
|
dofile(loud_walking.path.."/deco_trees.lua")
|
||||||
|
|
||||||
|
|
||||||
-- Re-register the good decorations.
|
local function register_flower(name, desc, biomes, chance)
|
||||||
-- This has to be done after registering the trees or
|
local groups = {}
|
||||||
-- the trees spawn on top of grass. /shrug
|
groups.snappy = 3
|
||||||
for _, i in pairs(decos) do
|
groups.flammable = 2
|
||||||
minetest.register_decoration(i)
|
groups.flower = 1
|
||||||
|
groups.flora = 1
|
||||||
|
groups.attached_node = 1
|
||||||
|
|
||||||
|
minetest.register_node("loud_walking:" .. name, {
|
||||||
|
description = desc,
|
||||||
|
drawtype = "plantlike",
|
||||||
|
waving = 1,
|
||||||
|
tiles = {"loud_walking_" .. name .. ".png"},
|
||||||
|
inventory_image = "loud_walking_" .. name .. ".png",
|
||||||
|
wield_image = "flowers_" .. name .. ".png",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype = "light",
|
||||||
|
walkable = false,
|
||||||
|
buildable_to = true,
|
||||||
|
stack_max = 99,
|
||||||
|
groups = groups,
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
local bi = {}
|
||||||
|
if biomes then
|
||||||
|
bi = {}
|
||||||
|
for _, b in pairs(biomes) do
|
||||||
|
bi[b] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
loud_walking.decorations[#loud_walking.decorations+1] = {
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"default:dirt_with_grass"},
|
||||||
|
biomes = bi,
|
||||||
|
fill_ratio = chance,
|
||||||
|
flower = true,
|
||||||
|
decoration = "loud_walking:"..name,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
register_flower("orchid", "Orchid", {"rainforest", "rainforest_swamp"}, 0.025)
|
||||||
|
register_flower("bird_of_paradise", "Bird of Paradise", {"rainforest", "desertstone_grassland"}, 0.025)
|
||||||
|
register_flower("gerbera", "Gerbera", {"savanna", "rainforest", "desertstone_grassland"}, 0.005)
|
||||||
|
|
||||||
|
|
||||||
|
local function register_decoration(deco, place_on, biomes, chance)
|
||||||
|
local bi = {}
|
||||||
|
if biomes then
|
||||||
|
bi = {}
|
||||||
|
for _, b in pairs(biomes) do
|
||||||
|
bi[b] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
loud_walking.decorations[#loud_walking.decorations+1] = {
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = place_on,
|
||||||
|
biomes = bi,
|
||||||
|
fill_ratio = chance,
|
||||||
|
decoration = deco,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if crops then
|
||||||
|
register_decoration(
|
||||||
|
"crops:pumpkin_plant_4",
|
||||||
|
{ "default:dirt_with_grass" },
|
||||||
|
{"stone_grassland", "sandstone_grassland", "deciduous_forest",
|
||||||
|
"coniferous_forest"},
|
||||||
|
0.002
|
||||||
|
)
|
||||||
|
register_decoration(
|
||||||
|
"crops:melon_plant_4",
|
||||||
|
{ "default:dirt_with_grass" },
|
||||||
|
{"deciduous_forest", "coniferous_forest", "tundra"},
|
||||||
|
0.002
|
||||||
|
)
|
||||||
|
register_decoration(
|
||||||
|
"crops:tomato_plant_4",
|
||||||
|
{ "default:dirt_with_grass" },
|
||||||
|
{"rainforest"},
|
||||||
|
0.002
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
default
|
default
|
||||||
flowers
|
flowers
|
||||||
|
crops?
|
||||||
|
ethereal?
|
||||||
|
farming?
|
||||||
|
farming_plus?
|
||||||
|
moreores?
|
||||||
|
|
12
init.lua
12
init.lua
|
@ -85,16 +85,10 @@ dofile(loud_walking.path .. "/mapgen.lua")
|
||||||
|
|
||||||
minetest.register_on_newplayer(loud_walking.respawn)
|
minetest.register_on_newplayer(loud_walking.respawn)
|
||||||
minetest.register_on_respawnplayer(loud_walking.respawn)
|
minetest.register_on_respawnplayer(loud_walking.respawn)
|
||||||
minetest.register_on_generated(loud_walking.generate)
|
|
||||||
|
-- Inserting helps to ensure that loud_walking operates first.
|
||||||
|
table.insert(minetest.registered_on_generateds, 1, loud_walking.generate)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
player:set_sky("#000000", "plain", {})
|
player:set_sky("#000000", "plain", {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function deco_list()
|
|
||||||
for i, deco in pairs(minetest.registered_decorations) do
|
|
||||||
print(dump(deco))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--deco_list()
|
|
||||||
|
|
|
@ -222,7 +222,6 @@ end
|
||||||
local function get_decoration(biome)
|
local function get_decoration(biome)
|
||||||
for i, deco in pairs(loud_walking.decorations) do
|
for i, deco in pairs(loud_walking.decorations) do
|
||||||
if not deco.biomes or deco.biomes[biome] then
|
if not deco.biomes or deco.biomes[biome] then
|
||||||
--local range = (string.find(biome, "rain") and deco.flower) and 500 or 1000
|
|
||||||
local range = 1000
|
local range = 1000
|
||||||
if deco.deco_type == "simple" then
|
if deco.deco_type == "simple" then
|
||||||
if deco.fill_ratio and math.random(range) - 1 < deco.fill_ratio * 1000 then
|
if deco.fill_ratio and math.random(range) - 1 < deco.fill_ratio * 1000 then
|
||||||
|
@ -266,7 +265,6 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
cave_lining = nil
|
cave_lining = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--print(biome)
|
|
||||||
vm:set_lighting({day = 15, night = (biome == "control" and 15 or 0)}, minp, maxp)
|
vm:set_lighting({day = 15, night = (biome == "control" and 15 or 0)}, minp, maxp)
|
||||||
lightmap = vm:get_light_data()
|
lightmap = vm:get_light_data()
|
||||||
|
|
||||||
|
@ -531,7 +529,7 @@ function loud_walking.generate(p_minp, p_maxp, seed)
|
||||||
|
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
minetest.generate_ores(vm, minp, maxp)
|
minetest.generate_ores(vm, minp, maxp)
|
||||||
minetest.generate_decorations(vm, minp, maxp)
|
--minetest.generate_decorations(vm, minp, maxp)
|
||||||
--vm:set_param2_data(p2data)
|
--vm:set_param2_data(p2data)
|
||||||
--vm:set_lighting({day = 15, night = 0})
|
--vm:set_lighting({day = 15, night = 0})
|
||||||
if pod then
|
if pod then
|
||||||
|
|
80
nodes.lua
80
nodes.lua
|
@ -125,86 +125,6 @@ minetest.register_node("loud_walking:controls", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
loud_walking.decorations = {}
|
|
||||||
do
|
|
||||||
for i, odeco in pairs(minetest.registered_decorations) do
|
|
||||||
local deco = {}
|
|
||||||
if odeco.biomes then
|
|
||||||
deco.biomes = {}
|
|
||||||
for _, b in pairs(odeco.biomes) do
|
|
||||||
deco.biomes[b] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
deco.deco_type = odeco.deco_type
|
|
||||||
deco.decoration = odeco.decoration
|
|
||||||
deco.schematic = odeco.schematic
|
|
||||||
deco.fill_ratio = odeco.fill_ratio
|
|
||||||
|
|
||||||
if odeco.noise_params then
|
|
||||||
deco.fill_ratio = (odeco.noise_params.scale + odeco.noise_params.offset)
|
|
||||||
end
|
|
||||||
|
|
||||||
local nod = minetest.registered_nodes[deco.decoration]
|
|
||||||
if nod and nod.groups and nod.groups.flower then
|
|
||||||
deco.flower = true
|
|
||||||
end
|
|
||||||
|
|
||||||
loud_walking.decorations[#loud_walking.decorations+1] = deco
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function register_flower(name, desc, biomes, chance)
|
|
||||||
local groups = {}
|
|
||||||
groups.snappy = 3
|
|
||||||
groups.flammable = 2
|
|
||||||
groups.flower = 1
|
|
||||||
groups.flora = 1
|
|
||||||
groups.attached_node = 1
|
|
||||||
|
|
||||||
minetest.register_node("loud_walking:" .. name, {
|
|
||||||
description = desc,
|
|
||||||
drawtype = "plantlike",
|
|
||||||
waving = 1,
|
|
||||||
tiles = {"loud_walking_" .. name .. ".png"},
|
|
||||||
inventory_image = "loud_walking_" .. name .. ".png",
|
|
||||||
wield_image = "flowers_" .. name .. ".png",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
paramtype = "light",
|
|
||||||
walkable = false,
|
|
||||||
buildable_to = true,
|
|
||||||
stack_max = 99,
|
|
||||||
groups = groups,
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
local bi = {}
|
|
||||||
if biomes then
|
|
||||||
bi = {}
|
|
||||||
for _, b in pairs(biomes) do
|
|
||||||
bi[b] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
loud_walking.decorations[#loud_walking.decorations+1] = {
|
|
||||||
deco_type = "simple",
|
|
||||||
place_on = {"default:dirt_with_grass"},
|
|
||||||
biomes = bi,
|
|
||||||
fill_ratio = chance,
|
|
||||||
flower = true,
|
|
||||||
decoration = "loud_walking:"..name,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
register_flower("orchid", "Orchid", {"rainforest", "rainforest_swamp"}, 0.025)
|
|
||||||
register_flower("bird_of_paradise", "Bird of Paradise", {"rainforest", "desertstone_grassland"}, 0.025)
|
|
||||||
register_flower("gerbera", "Gerbera", {"savanna", "rainforest", "desertstone_grassland"}, 0.005)
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("loud_walking:air_ladder", {
|
minetest.register_node("loud_walking:air_ladder", {
|
||||||
description = "Air Ladder",
|
description = "Air Ladder",
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
|
|
Loading…
Reference in New Issue