summaryrefslogtreecommitdiff
path: root/biome_lib/search_functions.lua
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-03-06 17:01:02 -0500
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-03-06 17:01:02 -0500
commitb21c3d368077aa3a1c42ff1582cda6263c018585 (patch)
tree4053ef589ef5c5b99f0a87b567207e8c52cf4c76 /biome_lib/search_functions.lua
parentec25fd83415d0ecb49f41295af3dc30f14850b2f (diff)
downloaddreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.gz
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.bz2
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.xz
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.zip
updated cottages, areasprotector, bees, biome_lib, technic, facade,
farming redo, homedecor, maptools, mesecons, moreblocks, moreores, pipeworks, quartz, travelnet, unified_inventory, unifieddyes, xban2 delete the playeranim mod, not 5.0.0 compatible.
Diffstat (limited to 'biome_lib/search_functions.lua')
-rw-r--r--biome_lib/search_functions.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/biome_lib/search_functions.lua b/biome_lib/search_functions.lua
new file mode 100644
index 0000000..d665b5f
--- /dev/null
+++ b/biome_lib/search_functions.lua
@@ -0,0 +1,60 @@
+
+-- function to decide if a node has a wall that's in verticals_list{}
+-- returns wall direction of valid node, or nil if invalid.
+
+function biome_lib:find_adjacent_wall(pos, verticals, randomflag)
+ local verts = dump(verticals)
+ if randomflag then
+ local walltab = {}
+
+ if string.find(verts, minetest.get_node({ x=pos.x-1, y=pos.y, z=pos.z }).name) then walltab[#walltab + 1] = 3 end
+ if string.find(verts, minetest.get_node({ x=pos.x+1, y=pos.y, z=pos.z }).name) then walltab[#walltab + 1] = 2 end
+ if string.find(verts, minetest.get_node({ x=pos.x , y=pos.y, z=pos.z-1 }).name) then walltab[#walltab + 1] = 5 end
+ if string.find(verts, minetest.get_node({ x=pos.x , y=pos.y, z=pos.z+1 }).name) then walltab[#walltab + 1] = 4 end
+
+ if #walltab > 0 then return walltab[math.random(1, #walltab)] end
+
+ else
+ if string.find(verts, minetest.get_node({ x=pos.x-1, y=pos.y, z=pos.z }).name) then return 3 end
+ if string.find(verts, minetest.get_node({ x=pos.x+1, y=pos.y, z=pos.z }).name) then return 2 end
+ if string.find(verts, minetest.get_node({ x=pos.x , y=pos.y, z=pos.z-1 }).name) then return 5 end
+ if string.find(verts, minetest.get_node({ x=pos.x , y=pos.y, z=pos.z+1 }).name) then return 4 end
+ end
+ return nil
+end
+
+-- Function to search downward from the given position, looking for the first
+-- node that matches the ground table. Returns the new position, or nil if
+-- height limit is exceeded before finding it.
+
+function biome_lib:search_downward(pos, heightlimit, ground)
+ for i = 0, heightlimit do
+ if string.find(dump(ground), minetest.get_node({x=pos.x, y=pos.y-i, z = pos.z}).name) then
+ return {x=pos.x, y=pos.y-i, z = pos.z}
+ end
+ end
+ return false
+end
+
+function biome_lib:find_open_side(pos)
+ if minetest.get_node({ x=pos.x-1, y=pos.y, z=pos.z }).name == "air" then
+ return {newpos = { x=pos.x-1, y=pos.y, z=pos.z }, facedir = 2}
+ end
+ if minetest.get_node({ x=pos.x+1, y=pos.y, z=pos.z }).name == "air" then
+ return {newpos = { x=pos.x+1, y=pos.y, z=pos.z }, facedir = 3}
+ end
+ if minetest.get_node({ x=pos.x, y=pos.y, z=pos.z-1 }).name == "air" then
+ return {newpos = { x=pos.x, y=pos.y, z=pos.z-1 }, facedir = 4}
+ end
+ if minetest.get_node({ x=pos.x, y=pos.y, z=pos.z+1 }).name == "air" then
+ return {newpos = { x=pos.x, y=pos.y, z=pos.z+1 }, facedir = 5}
+ end
+ return nil
+end
+
+-- "Record" the chunks being generated by the core mapgen
+
+minetest.register_on_generated(function(minp, maxp, blockseed)
+ biome_lib.blocklist_aircheck[#biome_lib.blocklist_aircheck + 1] = { minp, maxp }
+ biome_lib.blocklist_no_aircheck[#biome_lib.blocklist_no_aircheck + 1] = { minp, maxp }
+end)