From 7a5bda2986eb579158f6693c1ae4aa88bb985081 Mon Sep 17 00:00:00 2001 From: cale Date: Tue, 1 Mar 2016 19:17:16 +0100 Subject: [PATCH] added villages! (WIP!!!!!) --- mods/default/nodes.lua | 6 ++ mods/default/textures/default_andesite.png | Bin 0 -> 415 bytes mods/village/LICENSE.txt | 11 +++ mods/village/init.lua | 83 +++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 mods/default/textures/default_andesite.png create mode 100644 mods/village/LICENSE.txt create mode 100644 mods/village/init.lua diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 30779f8..638bdcc 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -652,6 +652,12 @@ minetest.register_node("default:desert_stone", { drop = "default:stone_item 5", }) +minetest.register_node("default:andesite", { + description = "Andesite", + tiles = {"default_andesite.png"}, + groups = {cracky = 3}, +}) + minetest.register_node("default:cobble", { description = "Cobble", tiles = {"default_cobble.png"}, diff --git a/mods/default/textures/default_andesite.png b/mods/default/textures/default_andesite.png new file mode 100644 index 0000000000000000000000000000000000000000..4a02047906b4f025b8019687a96ae1b61789817e GIT binary patch literal 415 zcmV;Q0bu@#P)>(`dozVGH&wr#_o&NLTuD>O0cS#>cG + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +http://www.gnu.org/licenses/lgpl-2.1.html diff --git a/mods/village/init.lua b/mods/village/init.lua new file mode 100644 index 0000000..cf3b0a6 --- /dev/null +++ b/mods/village/init.lua @@ -0,0 +1,83 @@ +minetest.register_on_generated(function(minp, maxp, seed) + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} + local data = vm:get_data() + + local heightmap = minetest.get_mapgen_object("heightmap") + + local c_air = minetest.get_content_id("air") + local c_stonebrick = minetest.get_content_id("default:stonebrick") + local c_wood = minetest.get_content_id("default:wood") + local c_wooden_planks = minetest.get_content_id("default:wooden_planks") + local c_wooden_planks_2 = minetest.get_content_id("default:wooden_planks_2") + + local c_glass = minetest.get_content_id("default:glass") + + local perlin1 = minetest.get_perlin(11,3, 0.5, 1) + local perlin2 = minetest.get_perlin(11,3, 0.5, 100) + + local h_index = 0 + + local first_height = math.floor(heightmap[1]/4)*4 + + for z = minp.z, maxp.z do + for x = minp.x, maxp.x do + h_index = h_index+1 + for y = minp.y, maxp.y do + local pos = area:index(x, y, z) + -- TODO : I think this is very slow... + local part = {x=math.floor(x/10)*10, y=math.floor(y/4)*4, z=math.floor(z/10)*10} + local h_part = math.floor(heightmap[h_index]/4)*4 + + local height = heightmap[h_index] + if perlin2:get2d({x=part.x, y=part.z}) > 0.9 then + if vector.equals({x=x, y=y, z=z}, part) then + first_height = math.floor(heightmap[h_index]/4)*4 + end + if math.abs(perlin1:get2d({x=part.x, y=part.z})) > 0.7 then + if y < (math.abs(perlin1:get2d({x=part.x, y=part.z})) * 8 -2) + first_height and y > height then + if y > -1 and x > part.x and z > part.z and x < part.x+9 and z < part.z+9 then + -- walls + if part.x+1 == x then + data[pos] = c_wood + end + if part.z+1 == z then + data[pos] = c_wood + end + + if part.x+8 == x then + data[pos] = c_wood + end + if part.z+8 == z then + data[pos] = c_wood + end + + -- roof/floor + if part.y == y then + data[pos] = c_wood + end + if part.y+3 == y then + data[pos] = c_wood + end + elseif height == y then + data[pos] = c_stonebrick + else + data[pos] = c_air + end + end + else + if height == y then + data[pos] = c_stonebrick + end + end + end + end + end + end + + vm:set_data(data) + --vm:set_lighting({day=0, night=0}) + vm:calc_lighting() + vm:write_to_map(data) + vm:update_liquids() +end)