mirror of
http://repo.or.cz/minetest_pyramids/tsm_pyramids.git
synced 2025-06-29 14:40:53 +02:00
Compare commits
8 Commits
0.7
...
desert_sto
Author | SHA1 | Date | |
---|---|---|---|
08a750820b | |||
7b0c42954f | |||
461326ad32 | |||
783a5d8666 | |||
9b9e4c1f50 | |||
9c6dc7908a | |||
d834170a7b | |||
b00f540567 |
89
init.lua
89
init.lua
@ -6,6 +6,8 @@ dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
|||||||
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/room.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/room.lua")
|
||||||
|
|
||||||
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||||
|
|
||||||
local chest_stuff = {
|
local chest_stuff = {
|
||||||
{name="default:apple", max = 3},
|
{name="default:apple", max = 3},
|
||||||
{name="default:steel_ingot", max = 3},
|
{name="default:steel_ingot", max = 3},
|
||||||
@ -33,7 +35,7 @@ end
|
|||||||
function tsm_pyramids.fill_chest(pos, stype, flood_sand)
|
function tsm_pyramids.fill_chest(pos, stype, flood_sand)
|
||||||
minetest.after(2, function()
|
minetest.after(2, function()
|
||||||
local sand = "default:sand"
|
local sand = "default:sand"
|
||||||
if stype == "desert" then
|
if stype == "desert_sandstone" or stype == "desert_stone" then
|
||||||
sand = "default:desert_sand"
|
sand = "default:desert_sand"
|
||||||
end
|
end
|
||||||
local n = minetest.get_node(pos)
|
local n = minetest.get_node(pos)
|
||||||
@ -83,16 +85,16 @@ local function can_replace(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function underground(pos, stone, sand)
|
local function make_foundation_part(pos, set_to_stone)
|
||||||
local p2 = pos
|
local p2 = pos
|
||||||
local cnt = 0
|
local cnt = 0
|
||||||
local mat = stone
|
|
||||||
p2.y = p2.y-1
|
p2.y = p2.y-1
|
||||||
while can_replace(p2)==true do
|
while can_replace(p2)==true do
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
if cnt > 25 then break end
|
if cnt > 25 then
|
||||||
if cnt>math.random(2,4) then mat = stone end
|
break
|
||||||
minetest.set_node(p2, {name=mat})
|
end
|
||||||
|
table.insert(set_to_stone, table.copy(p2))
|
||||||
p2.y = p2.y-1
|
p2.y = p2.y-1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -103,7 +105,7 @@ local function make_entrance(pos, brick, sand, flood_sand)
|
|||||||
for iz=0,6,1 do
|
for iz=0,6,1 do
|
||||||
local sand_height = math.random(1,max_sand_height)
|
local sand_height = math.random(1,max_sand_height)
|
||||||
for iy=2,3,1 do
|
for iy=2,3,1 do
|
||||||
if flood_sand and iy <= sand_height and iz >= 3 then
|
if flood_sand and sand ~= "ignore" and iy <= sand_height and iz >= 3 then
|
||||||
minetest.set_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz}, {name=sand})
|
minetest.set_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz}, {name=sand})
|
||||||
else
|
else
|
||||||
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
|
minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
|
||||||
@ -117,22 +119,39 @@ local function make_entrance(pos, brick, sand, flood_sand)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make(pos, brick, sandstone, stone, sand, ptype, room_id)
|
local function make_pyramid(pos, brick, sandstone, stone, sand)
|
||||||
|
local set_to_brick = {}
|
||||||
|
local set_to_sand = {}
|
||||||
|
local set_to_stone = {}
|
||||||
-- Build pyramid
|
-- Build pyramid
|
||||||
for iy=0,math.random(10,11),1 do
|
for iy=0,math.random(10,11),1 do
|
||||||
for ix=iy,22-iy,1 do
|
for ix=iy,22-iy,1 do
|
||||||
for iz=iy,22-iy,1 do
|
for iz=iy,22-iy,1 do
|
||||||
if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}, stone, sand) end
|
if iy < 1 then
|
||||||
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name=brick})
|
make_foundation_part({x=pos.x+ix,y=pos.y,z=pos.z+iz}, set_to_stone)
|
||||||
for yy=1,10-iy,1 do
|
end
|
||||||
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
table.insert(set_to_brick, {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz})
|
||||||
if n and n.name and n.name == stone then
|
if sand ~= "ignore" then
|
||||||
minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name=sand})
|
for yy=1,10-iy,1 do
|
||||||
|
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
||||||
|
if n and n.name and n.name == stone then
|
||||||
|
table.insert(set_to_sand, {x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
minetest.bulk_set_node(set_to_stone , {name=stone})
|
||||||
|
minetest.bulk_set_node(set_to_brick, {name=brick})
|
||||||
|
if sand ~= "ignore" then
|
||||||
|
minetest.bulk_set_node(set_to_sand, {name=sand})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function make(pos, brick, sandstone, stone, sand, ptype, room_id)
|
||||||
|
-- Build pyramid
|
||||||
|
make_pyramid(pos, brick, sandstone, stone, sand)
|
||||||
-- Build room
|
-- Build room
|
||||||
local ok, msg, flood_sand = tsm_pyramids.make_room(pos, ptype, room_id)
|
local ok, msg, flood_sand = tsm_pyramids.make_room(pos, ptype, room_id)
|
||||||
-- Place mummy spawner
|
-- Place mummy spawner
|
||||||
@ -181,7 +200,6 @@ end
|
|||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if maxp.y < 0 then return end
|
if maxp.y < 0 then return end
|
||||||
math.randomseed(seed)
|
math.randomseed(seed)
|
||||||
local cnt = 0
|
|
||||||
if not perlin1 then
|
if not perlin1 then
|
||||||
perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
||||||
end
|
end
|
||||||
@ -190,19 +208,26 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if noise1 > 0.25 or noise1 < -0.26 then
|
if noise1 > 0.25 or noise1 < -0.26 then
|
||||||
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||||
|
|
||||||
local sands = {"default:desert_sand", "default:sand"}
|
local sands = {"default:sand", "default:desert_sand", "default:desert_stone"}
|
||||||
local p2
|
local p2
|
||||||
|
local psand = {}
|
||||||
local sand
|
local sand
|
||||||
|
local cnt = 0
|
||||||
|
local cnt_min = 100
|
||||||
for s=1, #sands do
|
for s=1, #sands do
|
||||||
|
cnt = 0
|
||||||
sand = sands[s]
|
sand = sands[s]
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
psand[s] = minetest.find_node_near(mpos, 25, sand)
|
||||||
while p2 == nil and cnt < 5 do
|
while psand == nil and cnt < 5 do
|
||||||
cnt = cnt+1
|
cnt = cnt+1
|
||||||
mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
psand[s] = minetest.find_node_near(mpos, 25, sand)
|
||||||
end
|
end
|
||||||
if p2 ~= nil then
|
if psand[s] ~= nil then
|
||||||
break
|
if cnt < cnt_min then
|
||||||
|
cnt_min = cnt
|
||||||
|
p2 = psand[s]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if p2 == nil then return end
|
if p2 == nil then return end
|
||||||
@ -236,10 +261,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if math.random(0,10) > 7 then
|
if math.random(0,10) > 7 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if (mg_name == "v6" and sand == "default:desert_sand" and math.random(1, 2) == 1) then
|
||||||
|
sand = "default:sand"
|
||||||
|
end
|
||||||
if sand == "default:desert_sand" then
|
if sand == "default:desert_sand" then
|
||||||
minetest.after(0.8, make, p2, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert")
|
-- Desert sandstone pyramid
|
||||||
else
|
minetest.after(0.8, make, p2, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone")
|
||||||
|
elseif sand == "default:sand" then
|
||||||
|
-- Sandstone pyramid
|
||||||
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone")
|
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone")
|
||||||
|
else
|
||||||
|
-- Desert stone pyramid
|
||||||
|
minetest.after(0.8, make, p2, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "default:desert_sand", "desert_stone")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -269,17 +302,23 @@ minetest.register_chatcommand("spawnpyramid", {
|
|||||||
end
|
end
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
pos = vector.round(pos)
|
pos = vector.round(pos)
|
||||||
local s = math.random(1,2)
|
local s = math.random(1,3)
|
||||||
local r = tonumber(param)
|
local r = tonumber(param)
|
||||||
local room_id
|
local room_id
|
||||||
if r then
|
if r then
|
||||||
room_id = r
|
room_id = r
|
||||||
end
|
end
|
||||||
local ok, msg
|
local ok, msg
|
||||||
|
pos = vector.add(pos, {x=-11, y=-1, z=0})
|
||||||
if s == 1 then
|
if s == 1 then
|
||||||
|
-- Sandstone
|
||||||
ok, msg = make(pos, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone", room_id)
|
ok, msg = make(pos, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone", room_id)
|
||||||
|
elseif s == 2 then
|
||||||
|
-- Desert sandstone
|
||||||
|
ok, msg = make(pos, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone", room_id)
|
||||||
else
|
else
|
||||||
ok, msg = make(pos, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert", room_id)
|
-- Desert stone
|
||||||
|
ok, msg = make(pos, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "ignore", "desert_stone", room_id)
|
||||||
end
|
end
|
||||||
if ok then
|
if ok then
|
||||||
return true, S("Pyramid generated at @1.", minetest.pos_to_string(pos))
|
return true, S("Pyramid generated at @1.", minetest.pos_to_string(pos))
|
||||||
|
88
room.lua
88
room.lua
@ -542,55 +542,62 @@ local layout_traps_template = {
|
|||||||
|
|
||||||
local code_sandstone = {
|
local code_sandstone = {
|
||||||
[" "] = "air",
|
[" "] = "air",
|
||||||
["s"] = "sandstone",
|
["s"] = "default:sandstone",
|
||||||
["S"] = "sandstonebrick",
|
["S"] = "default:sandstonebrick",
|
||||||
["1"] = "deco_stone1",
|
["1"] = "tsm_pyramids:deco_stone1",
|
||||||
["2"] = "deco_stone2",
|
["2"] = "tsm_pyramids:deco_stone2",
|
||||||
["3"] = "deco_stone3",
|
["3"] = "tsm_pyramids:deco_stone3",
|
||||||
["^"] = "chest",
|
["^"] = "default:chest",
|
||||||
["<"] = "chest",
|
["<"] = "default:chest",
|
||||||
[">"] = "chest",
|
[">"] = "default:chest",
|
||||||
["v"] = "chest",
|
["v"] = "default:chest",
|
||||||
["~"] = "lava_source",
|
["~"] = "default:lava_source",
|
||||||
["t"] = "trap",
|
["t"] = "tsm_pyramids:trap",
|
||||||
}
|
}
|
||||||
local code_desert = table.copy(code_sandstone)
|
local code_desert_sandstone = table.copy(code_sandstone)
|
||||||
code_desert["s"] = "desert_sandstone"
|
code_desert_sandstone["s"] = "default:desert_sandstone"
|
||||||
code_desert["1"] = "deco_stone4"
|
code_desert_sandstone["1"] = "tsm_pyramids:deco_stone4"
|
||||||
code_desert["2"] = "deco_stone5"
|
code_desert_sandstone["2"] = "tsm_pyramids:deco_stone5"
|
||||||
code_desert["3"] = "deco_stone6"
|
code_desert_sandstone["3"] = "tsm_pyramids:deco_stone6"
|
||||||
code_desert["S"] = "desert_sandstone_brick"
|
code_desert_sandstone["S"] = "default:desert_sandstone_brick"
|
||||||
code_desert["t"] = "desert_trap"
|
code_desert_sandstone["t"] = "tsm_pyramids:desert_trap"
|
||||||
|
|
||||||
|
local code_desert_stone = table.copy(code_sandstone)
|
||||||
|
code_desert_stone["s"] = "default:desert_stone_block"
|
||||||
|
code_desert_stone["1"] = "default:desert_stone_block"
|
||||||
|
code_desert_stone["2"] = "default:desert_stone_block"
|
||||||
|
code_desert_stone["3"] = "default:desert_stone_block"
|
||||||
|
code_desert_stone["S"] = "default:desert_stonebrick"
|
||||||
|
-- TODO: Add desert stone trap?
|
||||||
|
code_desert_stone["t"] = "air"
|
||||||
|
|
||||||
local function replace(str, iy, code_table, deco, column_style)
|
local function replace(str, iy, code_table, deco, column_style)
|
||||||
local out = "default:"
|
|
||||||
if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
|
if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
|
||||||
if column_style == 1 or column_style == 2 then
|
if column_style == 1 or column_style == 2 then
|
||||||
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
|
if iy == 0 and str == "s" then str = deco[1] end
|
||||||
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = deco[2] end
|
if iy == 3 and str == "s" then str = deco[2] end
|
||||||
elseif column_style == 3 then
|
elseif column_style == 3 then
|
||||||
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
|
if iy == 0 and str == "s" then str = deco[1] end
|
||||||
if iy == 2 and str == "s" then out = "tsm_pyramids:" str = deco[2] end
|
if iy == 2 and str == "s" then str = deco[2] end
|
||||||
elseif column_style == 4 then
|
elseif column_style == 4 then
|
||||||
if iy == 2 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
|
if iy == 2 and str == "s" then str = deco[1] end
|
||||||
end
|
end
|
||||||
if str == " " then out = "" end
|
return code_table[str]
|
||||||
return out..code_table[str]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function replace2(str, iy, code_table)
|
local function replace2(str, iy, code_table)
|
||||||
local out = "default:"
|
if iy == 0 and str == "~" then str = "t"
|
||||||
if iy == 0 and str == "~" then out = "tsm_pyramids:" str = "t"
|
|
||||||
elseif iy < 3 and str == "~" then str = " " end
|
elseif iy < 3 and str == "~" then str = " " end
|
||||||
|
|
||||||
if str == " " then out = "" end
|
return code_table[str]
|
||||||
return out..code_table[str]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function tsm_pyramids.make_room(pos, stype, room_id)
|
function tsm_pyramids.make_room(pos, stype, room_id)
|
||||||
local code_table = code_sandstone
|
local code_table = code_sandstone
|
||||||
if stype == "desert" then
|
if stype == "desert_sandstone" then
|
||||||
code_table = code_desert
|
code_table = code_desert_sandstone
|
||||||
|
elseif stype == "desert_stone" then
|
||||||
|
code_table = code_desert_stone
|
||||||
end
|
end
|
||||||
-- Select random deco block
|
-- Select random deco block
|
||||||
local deco_ids = {"1", "2", "3"}
|
local deco_ids = {"1", "2", "3"}
|
||||||
@ -611,6 +618,9 @@ function tsm_pyramids.make_room(pos, stype, room_id)
|
|||||||
local room = room_types[room_id]
|
local room = room_types[room_id]
|
||||||
local chests = {}
|
local chests = {}
|
||||||
local column_style = math.random(0,4)
|
local column_style = math.random(0,4)
|
||||||
|
if stype == "desert_stone" then
|
||||||
|
column_style = 0
|
||||||
|
end
|
||||||
if room.style == "yrepeat" then
|
if room.style == "yrepeat" then
|
||||||
for iy=0,4,1 do
|
for iy=0,4,1 do
|
||||||
for ix=0,8,1 do
|
for ix=0,8,1 do
|
||||||
@ -638,7 +648,7 @@ function tsm_pyramids.make_room(pos, stype, room_id)
|
|||||||
else
|
else
|
||||||
minetest.log("error", "Invalid pyramid room style! room type ID="..r)
|
minetest.log("error", "Invalid pyramid room style! room type ID="..r)
|
||||||
end
|
end
|
||||||
local sanded = room.flood_sand ~= false and math.random(1,8) == 1
|
local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
|
||||||
if #chests > 0 then
|
if #chests > 0 then
|
||||||
-- Make at least 8 attempts to fill chests
|
-- Make at least 8 attempts to fill chests
|
||||||
local filled = 0
|
local filled = 0
|
||||||
@ -673,8 +683,10 @@ end
|
|||||||
|
|
||||||
function tsm_pyramids.make_traps(pos, stype)
|
function tsm_pyramids.make_traps(pos, stype)
|
||||||
local code_table = code_sandstone
|
local code_table = code_sandstone
|
||||||
if stype == "desert" then
|
if stype == "desert_sandstone" then
|
||||||
code_table = code_desert
|
code_table = code_desert_sandstone
|
||||||
|
elseif stype == "desert_stone" then
|
||||||
|
code_table = code_desert_stone
|
||||||
end
|
end
|
||||||
shuffle_traps(math.random(10,100))
|
shuffle_traps(math.random(10,100))
|
||||||
local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
|
local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
|
||||||
@ -690,8 +702,9 @@ function tsm_pyramids.make_traps(pos, stype)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function tsm_pyramids.flood_sand(pos, stype)
|
function tsm_pyramids.flood_sand(pos, stype)
|
||||||
|
local set_to_sand = {}
|
||||||
local nn = "default:sand"
|
local nn = "default:sand"
|
||||||
if stype == "desert" then
|
if stype == "desert_sandstone" or stype == "desert_stone" then
|
||||||
nn = "default:desert_sand"
|
nn = "default:desert_sand"
|
||||||
end
|
end
|
||||||
local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
|
local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
|
||||||
@ -704,11 +717,12 @@ function tsm_pyramids.flood_sand(pos, stype)
|
|||||||
for iy=0,h,1 do
|
for iy=0,h,1 do
|
||||||
local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
|
local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
|
||||||
if minetest.get_node(p).name == "air" then
|
if minetest.get_node(p).name == "air" then
|
||||||
minetest.set_node(p, {name=nn})
|
table.insert(set_to_sand, p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
minetest.bulk_set_node(set_to_sand, {name=nn})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user