From a89529237186cd47c9a670f12c2473173aa69741 Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 10 Jun 2022 03:12:45 +0200 Subject: [PATCH] Add API documentation, minor fixes --- mods/MAPGEN/mcl_geodes/init.lua | 2 +- mods/MAPGEN/mcl_structures/API.md | 27 +++++++++++++++++++++++++++ mods/MAPGEN/mcl_structures/api.lua | 1 + mods/MAPGEN/mcl_structures/init.lua | 5 ++--- mods/MAPGEN/mcl_structures/mod.conf | 4 ++-- 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 mods/MAPGEN/mcl_structures/API.md diff --git a/mods/MAPGEN/mcl_geodes/init.lua b/mods/MAPGEN/mcl_geodes/init.lua index 413a8fbba4..d2debf7cd5 100644 --- a/mods/MAPGEN/mcl_geodes/init.lua +++ b/mods/MAPGEN/mcl_geodes/init.lua @@ -8,7 +8,7 @@ local adjacents = { } local function makegeode(pos,pr) - local size = pr:next(4,12) + local size = pr:next(2,8) local p1 = vector.offset(pos,-size,-size,-size) local p2 = vector.offset(pos,size,size,size) local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"}) diff --git a/mods/MAPGEN/mcl_structures/API.md b/mods/MAPGEN/mcl_structures/API.md new file mode 100644 index 0000000000..52d40b642f --- /dev/null +++ b/mods/MAPGEN/mcl_structures/API.md @@ -0,0 +1,27 @@ +# mcl_structures +Structure placement API for MCL2. + +## mcl_structures.register_structure(name,structure definition) +### structure definition +{ + fill_ratio = OR noise = {}, + biomes = {}, + y_min =, + y_max =, + place_on = {}, + spawn_by = {}, + num_spawn_by = + flags = (default: "place_center_x, place_center_z, force_placement") + (same as decoration def) + y_offset =, --can be a number or a function returning a number + filenames = {} OR place_func = function(pos,filename) + -- filenames can be a list of any schematics accepted by mcl_structures.place_schematic + after_place = function(pos) +} +## mcl_structures.registered_structures +Table of the registered structure defintions indexed by name. + +## mcl_structures.place_structure(pos, def, pr) +Places a structure using the mapgen placement function + +## mcl_structures.place_schematic(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param) diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 5e0858fb1c..be86df5309 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -72,6 +72,7 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it end) end minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups}) + def.structblock = structblock mcl_structures.registered_structures[name] = def end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 665fbf4c06..a82dffbff7 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -630,9 +630,8 @@ minetest.register_on_mods_loaded(function() else for n,d in pairs(mcl_structures.registered_structures) do if n == param then - mcl_structures.place_structure(pos,d,PseudoRandom(os.clock())) - minetest.chat_send_player(name, message) - return + mcl_structures.place_structure(pos,d,pr) + return true,message end end message = S("Error: Unknown structure type. Please use “/spawnstruct ”.") diff --git a/mods/MAPGEN/mcl_structures/mod.conf b/mods/MAPGEN/mcl_structures/mod.conf index 3150c7cec0..c19113ad44 100644 --- a/mods/MAPGEN/mcl_structures/mod.conf +++ b/mods/MAPGEN/mcl_structures/mod.conf @@ -1,4 +1,4 @@ name = mcl_structures -author = Wuzzy -description = Structures for MCL2 +author = Wuzzy, cora +description = Structure placement for MCL2 depends = mcl_loot