Skip to content

Commit 0a8519a

Browse files
committedJun 17, 2013
Add initial Decoration support, many misc. improvements & modifications
1 parent eccd1fd commit 0a8519a

14 files changed

+659
-87
lines changed
 

‎doc/lua_api.txt

+48-1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,18 @@ Currently supported flags: absheight
410410
Also produce this same ore between the height range of -height_max and -height_min.
411411
Useful for having ore in sky realms without having to duplicate ore entries.
412412

413+
Decoration types
414+
-------------------
415+
The varying types of decorations that can be placed.
416+
The default value is simple, and is currently the only type supported.
417+
418+
- simple
419+
Creates a 1xHx1 column of a specified node (or a random node from a list, if a decoration
420+
list is specified). Can specify a certain node it must spawn next to, such as water or lava,
421+
for example. Can also generate a decoration of random height between a specified lower and
422+
upper bound. This type of decoration is intended for placement of grass, flowers, cacti,
423+
papyrus, and so on.
424+
413425
HUD element types
414426
-------------------
415427
The position field is used for all element types.
@@ -946,6 +958,7 @@ minetest.register_craftitem(name, item definition)
946958
minetest.register_alias(name, convert_to)
947959
minetest.register_craft(recipe)
948960
minetest.register_ore(ore definition)
961+
minetest.register_decoration(decoration definition)
949962

950963
Global callback registration functions: (Call these only at load time)
951964
minetest.register_globalstep(func(dtime))
@@ -1835,7 +1848,7 @@ Recipe for register_craft (furnace fuel)
18351848

18361849
Ore definition (register_ore)
18371850
{
1838-
ore_type = "scatter" -- See "Ore types"
1851+
ore_type = "scatter", -- See "Ore types"
18391852
ore = "default:stone_with_coal",
18401853
wherein = "default:stone",
18411854
clust_scarcity = 8*8*8,
@@ -1857,6 +1870,40 @@ Ore definition (register_ore)
18571870
^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution
18581871
}
18591872

1873+
Decoration definition (register_decoration)
1874+
{
1875+
deco_type = "simple", -- See "Decoration types"
1876+
place_on = "default:dirt_with_grass",
1877+
^ Node that decoration can be placed on
1878+
divlen = 8,
1879+
^ Number of divisions made in the chunk being generated
1880+
fill_ratio = 0.02,
1881+
^ Ratio of the area to be uniformly filled by the decoration.
1882+
^ Used only if noise_params is not specified.
1883+
noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7},
1884+
^ NoiseParams structure describing the perlin noise used for decoration distribution.
1885+
^ The result of this is multiplied by the 2d area of the division being decorated.
1886+
biomes = {"Oceanside", "Hills", "Plains"},
1887+
^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted,
1888+
^ and ignored if the Mapgen being used does not support biomes.
1889+
1890+
----- Simple-type parameters
1891+
decoration = "default:grass",
1892+
^ The node name used as the decoration.
1893+
^ If instead a list of strings, a randomly selected node from the list is placed as the decoration.
1894+
height = 1,
1895+
^ Number of nodes high the decoration is made.
1896+
^ If height_max is not 0, this is the lower bound of the randomly selected height.
1897+
height_max = 0,
1898+
^ Number of nodes the decoration can be at maximum.
1899+
^ If absent, the parameter 'height' is used as a constant.
1900+
spawn_by = "default:water",
1901+
^ Node that the decoration only spawns next to, in a 1-node square radius.
1902+
num_spawn_by = 1,
1903+
^ Number of spawn_by nodes that must be surrounding the decoration position to occur.
1904+
^ If absent or -1, decorations occur next to any nodes.
1905+
}
1906+
18601907
Chatcommand definition (register_chatcommand)
18611908
{
18621909
params = "<name> <privilege>", -- short parameter description

‎src/biome.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,13 @@ Biome *BiomeDefManager::getBiome(float heat, float humidity, s16 y) {
168168

169169
return biome_closest ? biome_closest : biomes[0];
170170
}
171+
172+
173+
u8 BiomeDefManager::getBiomeIdByName(const char *name) {
174+
for (size_t i = 0; i != biomes.size(); i++) {
175+
if (!strcasecmp(name, biomes[i]->name.c_str()))
176+
return i;
177+
}
178+
179+
return 0;
180+
}

‎src/biome.h

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class BiomeDefManager {
8484

8585
void addBiome(Biome *b);
8686
void resolveNodeNames(INodeDefManager *ndef);
87+
u8 getBiomeIdByName(const char *name);
8788
};
8889

8990
#endif

‎src/defaultsettings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void set_default_settings(Settings *settings)
239239
settings->setDefault("mgv7_np_terrain_mod", "0, 1, (350, 350, 350), 85039, 5, 0.6");
240240
settings->setDefault("mgv7_np_terrain_persist", "0, 1, (500, 500, 500), 539, 3, 0.6");
241241
settings->setDefault("mgv7_np_height_select", "0.5, 0.5, (250, 250, 250), 4213, 5, 0.69");
242-
settings->setDefault("mgv7_np_ridge", "0.5, 1, (100, 100, 100), 6467, 4, 0.75");
242+
settings->setDefault("mgv7_np_ridge", "0, 1, (100, 100, 100), 6467, 4, 0.75");
243243

244244
settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10");
245245
settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10");

‎src/emerge.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ EmergeManager::~EmergeManager() {
101101
for (unsigned int i = 0; i < ores.size(); i++)
102102
delete ores[i];
103103
ores.clear();
104+
105+
for (unsigned int i = 0; i < decorations.size(); i++)
106+
delete decorations[i];
107+
decorations.clear();
104108

105109
for (std::map<std::string, MapgenFactory *>::iterator iter = mglist.begin();
106110
iter != mglist.end(); iter ++) {

‎src/emerge.h

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class EmergeManager {
8787
//Mapgen-related structures
8888
BiomeDefManager *biomedef;
8989
std::vector<Ore *> ores;
90+
std::vector<Decoration *> decorations;
9091

9192
EmergeManager(IGameDef *gamedef);
9293
~EmergeManager();

0 commit comments

Comments
 (0)
Please sign in to comment.