Initial commit
parent
fd4176708f
commit
c0e8a73614
|
@ -0,0 +1,14 @@
|
|||
# ziggurat
|
||||
|
||||
This mod places ziggurats in desert and jungle biomes. They're full of sealed, stone chambers, occasionally containing a treasure chest (if you're running my booty mod). Living mummies, horrible curses, and savage priests are not included.
|
||||
|
||||
![screenshot](https://raw.githubusercontent.com/duane-r/zigg/master/screenshot1.png)
|
||||
|
||||
|
||||
The source is available on github.
|
||||
|
||||
Code: LGPL2
|
||||
|
||||
Mod dependencies: default
|
||||
|
||||
Download: https://github.com/duane-r/zigg/archive/master.zip
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
booty?
|
|
@ -0,0 +1,23 @@
|
|||
-- Zigg init.lua
|
||||
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
||||
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
|
||||
zigg_mod = {}
|
||||
zigg_mod.version = "1.0"
|
||||
zigg_mod.path = minetest.get_modpath(minetest.get_current_modname())
|
||||
zigg_mod.world = minetest.get_worldpath()
|
||||
|
||||
|
||||
function zigg_mod.clone_node(name)
|
||||
if not (name and type(name) == 'string') then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.registered_nodes[name]
|
||||
local node2 = table.copy(node)
|
||||
return node2
|
||||
end
|
||||
|
||||
|
||||
dofile(zigg_mod.path .. "/mapgen.lua")
|
|
@ -0,0 +1,106 @@
|
|||
-- Ziggurat mapgen.lua
|
||||
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
||||
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
|
||||
local DEBUG
|
||||
local max_depth = 31000
|
||||
local seed_noise = {offset = 0, scale = 32768, seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, persist = 0.4, lacunarity = 2}
|
||||
|
||||
|
||||
-- This tables looks up nodes that aren't already stored.
|
||||
local node = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
if not (t and k and type(t) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
t[k] = minetest.get_content_id(k)
|
||||
return t[k]
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
local biome_ids = {}
|
||||
if true or zigg_mod.use_bi_hi then
|
||||
-- Create a table of biome ids, so I can use the biomemap.
|
||||
local get_biome_id = minetest.get_biome_id
|
||||
for name, desc in pairs(minetest.registered_biomes) do
|
||||
biome_ids[get_biome_id(desc.name)] = desc.name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local data = {}
|
||||
|
||||
|
||||
local function generate(p_minp, p_maxp, seed)
|
||||
if not (p_minp and p_maxp and seed) then
|
||||
return
|
||||
end
|
||||
|
||||
local minp, maxp = p_minp, p_maxp
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
if not (vm and emin and emax) then
|
||||
return
|
||||
end
|
||||
|
||||
vm:get_data(data)
|
||||
local heightmap
|
||||
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
||||
|
||||
if true or zigg_mod.use_bi_hi then
|
||||
heightmap = minetest.get_mapgen_object("heightmap")
|
||||
end
|
||||
|
||||
local biomemap
|
||||
if true or zigg_mod.use_bi_hi then
|
||||
biomemap = minetest.get_mapgen_object("biomemap")
|
||||
end
|
||||
|
||||
-- use the same seed (based on perlin noise).
|
||||
do
|
||||
local seed = minetest.get_perlin(seed_noise):get2d({x=minp.x, y=minp.z})
|
||||
if not (seed and type(seed) == 'number') then
|
||||
return
|
||||
end
|
||||
|
||||
math.randomseed(seed)
|
||||
end
|
||||
|
||||
local write = zigg_mod.ziggurat(minp, maxp, data, area, biomemap, biome_ids, node, heightmap)
|
||||
|
||||
if write then
|
||||
vm:set_data(data)
|
||||
|
||||
if DEBUG then
|
||||
vm:set_lighting({day = 8, night = 8})
|
||||
else
|
||||
vm:set_lighting({day = 0, night = 0}, minp, maxp)
|
||||
vm:calc_lighting()
|
||||
end
|
||||
vm:update_liquids()
|
||||
vm:write_to_map()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if zigg_mod.path then
|
||||
dofile(zigg_mod.path .. "/ziggurat.lua")
|
||||
end
|
||||
|
||||
|
||||
local function pgenerate(...)
|
||||
local status, err = pcall(generate, ...)
|
||||
--local status, err = true
|
||||
--generate(...)
|
||||
if not status then
|
||||
print('Treegen: Could not generate terrain:')
|
||||
print(dump(err))
|
||||
collectgarbage("collect")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_on_generated(pgenerate)
|
Binary file not shown.
After Width: | Height: | Size: 384 KiB |
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
Binary file not shown.
After Width: | Height: | Size: 637 B |
|
@ -0,0 +1,116 @@
|
|||
-- Ziggurat ziggurat.lua
|
||||
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
||||
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
|
||||
local max_depth = 31000
|
||||
local ziggurat_rarity = 20 -- 20
|
||||
local biome_rarity = 5 -- 5
|
||||
|
||||
-- ziggurat stone
|
||||
newnode = zigg_mod.clone_node("default:sandstone")
|
||||
newnode.description = "Pyramid Stone"
|
||||
newnode.tiles = {'zigg_ziggurat_stone.png'}
|
||||
newnode.groups.ziggurat = 1
|
||||
newnode.drop = 'default:sandstone'
|
||||
minetest.register_node("zigg:ziggurat_1", newnode)
|
||||
|
||||
|
||||
local ziggurat_biomes = {}
|
||||
for _, i in pairs({"rainforest", "desert", "desertstone_grassland", }) do
|
||||
ziggurat_biomes[i] = true
|
||||
end
|
||||
|
||||
local ziggurat_noise_1 = {offset = 0, scale = 1, seed = -6012, spread = {x = 20, y = 10, z = 20}, octaves = 6, persist = 1, lacunarity = 2}
|
||||
|
||||
|
||||
zigg_mod.ziggurat = function(minp, maxp, data, area, biomemap, biome_ids, node, heightmap)
|
||||
if not (minp and maxp and data and area and node and type(data) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
if math.random(ziggurat_rarity) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if biomemap then
|
||||
local biome = biome_ids[biomemap[3240]]
|
||||
if not (zigg_mod.ziggurats_everywhere or ziggurat_biomes[biome]) then
|
||||
return
|
||||
end
|
||||
elseif math.random(biome_rarity) ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local min_y = 80
|
||||
local index = 0
|
||||
for z = minp.z, maxp.z do
|
||||
local dz = z - minp.z
|
||||
for x = minp.x, maxp.x do
|
||||
local dx = x - minp.x
|
||||
index = index + 1
|
||||
if dz > 8 and dz < 72 and dx > 8 and dx < 72 and heightmap[index] - minp.y < 0 then
|
||||
return
|
||||
elseif heightmap[index] - minp.y < min_y then
|
||||
min_y = heightmap[index] - minp.y
|
||||
end
|
||||
end
|
||||
end
|
||||
if min_y >= 72 or heightmap[3240] >= 72 then
|
||||
return
|
||||
end
|
||||
|
||||
local base_height = math.min(min_y, 35)
|
||||
|
||||
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
||||
local map_max = {x = csize.x, y = csize.y, z = csize.z}
|
||||
local map_min = {x = minp.x, y = minp.y, z = minp.z}
|
||||
|
||||
local ziggurat_1 = minetest.get_perlin_map(ziggurat_noise_1, map_max):get3dMap_flat(map_min)
|
||||
if not ziggurat_1 then
|
||||
return
|
||||
end
|
||||
|
||||
local write = true
|
||||
local p2write = false
|
||||
|
||||
index = 0
|
||||
local index3d = 0
|
||||
for z = minp.z, maxp.z do
|
||||
local dz = z - minp.z
|
||||
for x = minp.x, maxp.x do
|
||||
local dx = x - minp.x
|
||||
index = index + 1
|
||||
index3d = math.floor((z - minp.z) / 5) * (csize.y) * csize.x + math.floor((x - minp.x) / 5) + 1
|
||||
local ivm = area:index(x, minp.y, z)
|
||||
|
||||
for y = minp.y, maxp.y do
|
||||
local dy = y - minp.y
|
||||
|
||||
if dy >= base_height + 3 and dy <= base_height + 37 - math.max(math.abs(dx - 40), math.abs(dz - 40)) and ziggurat_1[index3d] > 0 then
|
||||
if data[ivm - area.ystride] == node['zigg:ziggurat_1'] and math.random(50) == 1 then
|
||||
if minetest.registered_items['booty:coffer'] then
|
||||
data[ivm] = node['booty:coffer']
|
||||
else
|
||||
data[ivm] = node['default:chest']
|
||||
end
|
||||
else
|
||||
data[ivm] = node['air']
|
||||
end
|
||||
elseif dy >= base_height + 3 and dy <= base_height + 37 - math.max(math.abs(dx - 40), math.abs(dz - 40)) then
|
||||
data[ivm] = node['zigg:ziggurat_1']
|
||||
elseif dy >= base_height and dy <= base_height + 40 - math.max(math.abs(dx - 40), math.abs(dz - 40)) then
|
||||
data[ivm] = node['default:sandstone_block']
|
||||
end
|
||||
|
||||
ivm = ivm + area.ystride
|
||||
if dy % 5 == 0 then
|
||||
index3d = index3d + csize.x
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return write, p2write
|
||||
end
|
Loading…
Reference in New Issue