2019-08-20 00:27:25 +02:00
|
|
|
local S = minetest.get_translator("tsm_pyramids")
|
|
|
|
|
2019-08-23 17:13:15 +02:00
|
|
|
-- Pyramid width (must be an odd number)
|
|
|
|
local PYRA_W = 23
|
|
|
|
-- Pyramid width minus 1
|
|
|
|
local PYRA_Wm = PYRA_W - 1
|
|
|
|
-- Half of (Pyramid width minus 1)
|
|
|
|
local PYRA_Wh = PYRA_Wm / 2
|
|
|
|
|
2019-08-19 18:06:55 +02:00
|
|
|
tsm_pyramids = {}
|
2013-09-26 01:37:24 +02:00
|
|
|
|
2014-10-04 08:38:08 +02:00
|
|
|
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
|
|
|
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
|
|
|
dofile(minetest.get_modpath("tsm_pyramids").."/room.lua")
|
2013-09-16 21:24:44 +02:00
|
|
|
|
2019-08-20 17:05:45 +02:00
|
|
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
|
|
|
|
2013-09-16 21:23:16 +02:00
|
|
|
local chest_stuff = {
|
|
|
|
{name="default:apple", max = 3},
|
2019-08-20 01:52:43 +02:00
|
|
|
{name="default:steel_ingot", max = 3},
|
|
|
|
{name="default:copper_ingot", max = 3},
|
2013-09-16 21:23:16 +02:00
|
|
|
{name="default:gold_ingot", max = 2},
|
|
|
|
{name="default:diamond", max = 1},
|
|
|
|
{name="default:pick_steel", max = 1},
|
2019-08-20 01:52:43 +02:00
|
|
|
{name="default:pick_diamond", max = 1},
|
|
|
|
{name="default:papyrus", max = 9},
|
2013-09-16 21:23:16 +02:00
|
|
|
}
|
|
|
|
|
2019-08-20 01:52:43 +02:00
|
|
|
if minetest.get_modpath("farming") then
|
|
|
|
table.insert(chest_stuff, {name="farming:bread", max = 3})
|
|
|
|
table.insert(chest_stuff, {name="farming:cotton", max = 8})
|
|
|
|
else
|
|
|
|
table.insert(chest_stuff, {name="farming:apple", max = 8})
|
|
|
|
table.insert(chest_stuff, {name="farming:apple", max = 3})
|
|
|
|
end
|
|
|
|
if minetest.get_modpath("tnt") then
|
|
|
|
table.insert(chest_stuff, {name="tnt:gunpowder", max = 6})
|
|
|
|
else
|
|
|
|
table.insert(chest_stuff, {name="farming:apple", max = 3})
|
|
|
|
end
|
|
|
|
|
2019-08-20 03:14:39 +02:00
|
|
|
function tsm_pyramids.fill_chest(pos, stype, flood_sand)
|
2013-09-16 21:23:16 +02:00
|
|
|
minetest.after(2, function()
|
2019-08-20 03:14:39 +02:00
|
|
|
local sand = "default:sand"
|
2019-08-20 20:16:11 +02:00
|
|
|
if stype == "desert_sandstone" or stype == "desert_stone" then
|
2019-08-20 03:14:39 +02:00
|
|
|
sand = "default:desert_sand"
|
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
local n = minetest.get_node(pos)
|
2013-09-26 01:37:24 +02:00
|
|
|
if n and n.name and n.name == "default:chest" then
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size("main", 8*4)
|
2014-10-09 17:21:08 +02:00
|
|
|
local stacks = {}
|
2019-08-20 03:14:39 +02:00
|
|
|
-- Fill with sand in sand-flooded pyramids
|
|
|
|
if flood_sand then
|
2019-08-20 03:26:54 +02:00
|
|
|
table.insert(stacks, {name=sand, count = math.random(1,32)})
|
2019-08-20 03:14:39 +02:00
|
|
|
end
|
|
|
|
-- Add treasures
|
|
|
|
if math.random(1,10) >= 7 then
|
|
|
|
if minetest.get_modpath("treasurer") ~= nil then
|
|
|
|
stacks = treasurer.select_random_treasures(3,7,9,{"minetool", "food", "crafting_component"})
|
|
|
|
else
|
|
|
|
for i=0,2,1 do
|
|
|
|
local stuff = chest_stuff[math.random(1,#chest_stuff)]
|
|
|
|
table.insert(stacks, {name=stuff.name, count = math.random(1,stuff.max)})
|
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
|
|
|
end
|
2014-10-09 17:21:08 +02:00
|
|
|
for s=1,#stacks do
|
|
|
|
if not inv:contains_item("main", stacks[s]) then
|
|
|
|
inv:set_stack("main", math.random(1,32), stacks[s])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2019-08-20 04:22:20 +02:00
|
|
|
local function add_spawner(pos, mummy_offset)
|
2014-10-04 08:38:08 +02:00
|
|
|
minetest.set_node(pos, {name="tsm_pyramids:spawner_mummy"})
|
2019-08-20 04:22:20 +02:00
|
|
|
if not minetest.settings:get_bool("only_peaceful_mobs") then tsm_pyramids.spawn_mummy(vector.add(pos, mummy_offset),2) end
|
2013-09-26 01:37:24 +02:00
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
|
2013-09-26 01:37:24 +02:00
|
|
|
local function can_replace(pos)
|
|
|
|
local n = minetest.get_node_or_nil(pos)
|
|
|
|
if n and n.name and minetest.registered_nodes[n.name] and not minetest.registered_nodes[n.name].walkable then
|
|
|
|
return true
|
|
|
|
elseif not n then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-20 14:40:46 +02:00
|
|
|
local function make_foundation_part(pos, set_to_stone)
|
2013-09-26 01:37:24 +02:00
|
|
|
local p2 = pos
|
|
|
|
local cnt = 0
|
|
|
|
p2.y = p2.y-1
|
|
|
|
while can_replace(p2)==true do
|
|
|
|
cnt = cnt+1
|
2019-08-20 14:40:46 +02:00
|
|
|
if cnt > 25 then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
table.insert(set_to_stone, table.copy(p2))
|
2013-09-26 01:37:24 +02:00
|
|
|
p2.y = p2.y-1
|
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
|
|
|
|
2019-08-22 14:50:26 +02:00
|
|
|
local function make_entrance(pos, rot, brick, sand, flood_sand)
|
|
|
|
local roffset_arr = {
|
|
|
|
{ x=0, y=0, z=1 }, -- front
|
|
|
|
{ x=-1, y=0, z=0 }, -- left
|
|
|
|
{ x=0, y=0, z=-1 }, -- back
|
|
|
|
{ x=1, y=0, z=0 }, -- right
|
|
|
|
}
|
|
|
|
local roffset = roffset_arr[rot + 1]
|
|
|
|
local way
|
|
|
|
if rot == 0 then
|
2019-08-23 17:13:15 +02:00
|
|
|
way = vector.add(pos, {x=PYRA_Wh, y=0, z=0})
|
2019-08-22 14:50:26 +02:00
|
|
|
elseif rot == 1 then
|
2019-08-23 17:13:15 +02:00
|
|
|
way = vector.add(pos, {x=PYRA_Wm, y=0, z=PYRA_Wh})
|
2019-08-22 14:50:26 +02:00
|
|
|
elseif rot == 2 then
|
2019-08-23 17:13:15 +02:00
|
|
|
way = vector.add(pos, {x=PYRA_Wh, y=0, z=PYRA_Wm})
|
2019-08-22 14:50:26 +02:00
|
|
|
else
|
2019-08-23 17:13:15 +02:00
|
|
|
way = vector.add(pos, {x=0, y=0, z=PYRA_Wh})
|
2019-08-22 14:50:26 +02:00
|
|
|
end
|
2019-08-20 02:58:37 +02:00
|
|
|
local max_sand_height = math.random(1,3)
|
2019-08-22 14:50:26 +02:00
|
|
|
for ie=0,6,1 do
|
2019-08-20 02:58:37 +02:00
|
|
|
local sand_height = math.random(1,max_sand_height)
|
|
|
|
for iy=2,3,1 do
|
2019-08-22 14:50:26 +02:00
|
|
|
-- dig hallway
|
|
|
|
local way_dir = vector.add(vector.add(way, {x=0,y=iy,z=0}), vector.multiply(roffset, ie))
|
2019-08-23 12:58:27 +02:00
|
|
|
if flood_sand and sand ~= "ignore" and iy <= sand_height and ie >= 3 then
|
2019-08-22 14:50:26 +02:00
|
|
|
minetest.set_node(way_dir, {name=sand})
|
2019-08-20 02:58:37 +02:00
|
|
|
else
|
2019-08-22 14:50:26 +02:00
|
|
|
minetest.remove_node(way_dir)
|
2019-08-20 02:58:37 +02:00
|
|
|
end
|
2019-08-22 14:50:26 +02:00
|
|
|
-- build decoration above entrance
|
|
|
|
if ie >=3 and iy == 3 then
|
|
|
|
local deco = {x=way_dir.x, y=way_dir.y+1,z=way_dir.z}
|
|
|
|
minetest.set_node(deco, {name=brick})
|
|
|
|
if rot == 0 or rot == 2 then
|
|
|
|
minetest.set_node(vector.add(deco, {x=-1, y=0, z=0}), {name=brick})
|
|
|
|
minetest.set_node(vector.add(deco, {x=1, y=0, z=0}), {name=brick})
|
|
|
|
else
|
|
|
|
minetest.set_node(vector.add(deco, {x=0, y=0, z=-1}), {name=brick})
|
|
|
|
minetest.set_node(vector.add(deco, {x=0, y=0, z=1}), {name=brick})
|
|
|
|
end
|
2016-12-30 14:22:38 +01:00
|
|
|
end
|
2013-09-16 21:24:44 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
|
2019-08-20 14:40:46 +02:00
|
|
|
local function make_pyramid(pos, brick, sandstone, stone, sand)
|
|
|
|
local set_to_brick = {}
|
|
|
|
local set_to_sand = {}
|
|
|
|
local set_to_stone = {}
|
2019-08-20 04:22:20 +02:00
|
|
|
-- Build pyramid
|
2019-08-23 17:13:15 +02:00
|
|
|
for iy=0,math.random(10,PYRA_Wh),1 do
|
|
|
|
for ix=iy,PYRA_W-1-iy,1 do
|
|
|
|
for iz=iy,PYRA_W-1-iy,1 do
|
2019-08-20 14:40:46 +02:00
|
|
|
if iy < 1 then
|
|
|
|
make_foundation_part({x=pos.x+ix,y=pos.y,z=pos.z+iz}, set_to_stone)
|
|
|
|
end
|
|
|
|
table.insert(set_to_brick, {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz})
|
2019-08-20 20:47:11 +02:00
|
|
|
if sand ~= "ignore" then
|
|
|
|
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
|
2016-12-30 14:22:38 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-10-01 14:37:40 +02:00
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
2019-08-20 14:40:46 +02:00
|
|
|
minetest.bulk_set_node(set_to_stone , {name=stone})
|
|
|
|
minetest.bulk_set_node(set_to_brick, {name=brick})
|
2019-08-20 20:47:11 +02:00
|
|
|
if sand ~= "ignore" then
|
|
|
|
minetest.bulk_set_node(set_to_sand, {name=sand})
|
|
|
|
end
|
2019-08-20 14:40:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function make(pos, brick, sandstone, stone, sand, ptype, room_id)
|
|
|
|
-- Build pyramid
|
|
|
|
make_pyramid(pos, brick, sandstone, stone, sand)
|
2019-08-22 14:50:26 +02:00
|
|
|
|
|
|
|
local rot = math.random(0, 3)
|
2019-08-20 04:22:20 +02:00
|
|
|
-- Build room
|
2019-08-22 14:50:26 +02:00
|
|
|
local ok, msg, flood_sand = tsm_pyramids.make_room(pos, ptype, room_id, rot)
|
2019-08-20 04:22:20 +02:00
|
|
|
-- Place mummy spawner
|
2019-08-20 04:05:20 +02:00
|
|
|
local r = math.random(1,3)
|
2019-08-22 14:50:26 +02:00
|
|
|
-- 4 possible spawner positions
|
|
|
|
local spawner_posses = {
|
2019-08-20 04:22:20 +02:00
|
|
|
-- front
|
2019-08-23 17:13:15 +02:00
|
|
|
{{x=pos.x+PYRA_Wh,y=pos.y+2, z=pos.z+5}, {x=0, y=0, z=2}},
|
2019-08-20 04:22:20 +02:00
|
|
|
-- left
|
2019-08-23 17:13:15 +02:00
|
|
|
{{x=pos.x+PYRA_Wm-5,y=pos.y+2, z=pos.z+PYRA_Wh}, {x=-2, y=0, z=0}},
|
2019-08-22 14:50:26 +02:00
|
|
|
-- back
|
2019-08-23 17:13:15 +02:00
|
|
|
{{x=pos.x+PYRA_Wh,y=pos.y+2, z=pos.z+PYRA_W-5}, {x=0, y=0, z=-2}},
|
2019-08-22 14:50:26 +02:00
|
|
|
-- right
|
2019-08-23 17:13:15 +02:00
|
|
|
{{x=pos.x+5,y=pos.y+2, z=pos.z+PYRA_Wh}, {x=2, y=0, z=0}},
|
2019-08-22 14:50:26 +02:00
|
|
|
}
|
|
|
|
-- Delete the spawner position in which the entrance will be placed
|
|
|
|
table.remove(spawner_posses, (rot % 4) + 1)
|
|
|
|
add_spawner(spawner_posses[r][1], spawner_posses[r][2])
|
2019-08-20 04:22:20 +02:00
|
|
|
-- Build entrance
|
2019-08-22 14:50:26 +02:00
|
|
|
make_entrance(pos, rot, brick, sand, flood_sand)
|
2019-08-20 04:22:20 +02:00
|
|
|
-- Done
|
2019-08-20 01:07:42 +02:00
|
|
|
minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
|
|
|
|
return ok, msg
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
|
|
|
|
2013-09-26 01:37:24 +02:00
|
|
|
local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise.
|
2018-05-25 00:45:30 +02:00
|
|
|
local perlin1
|
2013-09-16 21:24:44 +02:00
|
|
|
|
2013-10-01 14:37:40 +02:00
|
|
|
local function hlp_fnct(pos, name)
|
|
|
|
local n = minetest.get_node_or_nil(pos)
|
|
|
|
if n and n.name and n.name == name then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2013-09-26 01:37:24 +02:00
|
|
|
local function ground(pos, old)
|
2013-09-16 21:24:44 +02:00
|
|
|
local p2 = pos
|
2013-10-01 14:37:40 +02:00
|
|
|
while hlp_fnct(p2, "air") do
|
2013-09-16 21:24:44 +02:00
|
|
|
p2.y = p2.y -1
|
|
|
|
end
|
2013-09-26 01:37:24 +02:00
|
|
|
if p2.y < old.y then
|
|
|
|
return p2
|
|
|
|
else
|
|
|
|
return old
|
|
|
|
end
|
2013-09-16 21:24:44 +02:00
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
minetest.register_on_generated(function(minp, maxp, seed)
|
2013-09-26 01:37:24 +02:00
|
|
|
if maxp.y < 0 then return end
|
|
|
|
math.randomseed(seed)
|
2018-05-25 00:45:30 +02:00
|
|
|
if not perlin1 then
|
|
|
|
perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
|
|
|
end
|
2019-08-23 18:51:32 +02:00
|
|
|
--[[ Make sure the pyramid doesn't bleed outside of maxp,
|
|
|
|
so it doesn't get placed incompletely by the mapgen.
|
|
|
|
This creates a bias somewhat, as this means there are some coordinates in
|
|
|
|
which pyramids cannot spawn. But it's still better to have broken pyramids.
|
|
|
|
]]
|
|
|
|
local limit = function(pos, maxp)
|
|
|
|
pos.x = math.min(pos.x, maxp.x - PYRA_W+1)
|
|
|
|
pos.y = math.min(pos.y, maxp.y - PYRA_Wh)
|
|
|
|
pos.z = math.min(pos.z, maxp.z - PYRA_W+1)
|
|
|
|
return pos
|
|
|
|
end
|
2019-08-19 18:08:34 +02:00
|
|
|
local noise1 = perlin1:get_2d({x=minp.x,y=minp.y})--,z=minp.z})
|
2016-12-30 14:22:38 +01:00
|
|
|
|
2013-09-26 01:37:24 +02:00
|
|
|
if noise1 > 0.25 or noise1 < -0.26 then
|
2016-12-30 14:22:38 +01:00
|
|
|
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
2013-09-16 21:24:44 +02:00
|
|
|
|
2019-08-23 13:00:35 +02:00
|
|
|
-- TODO: Re-activate desert stone pyramid
|
|
|
|
local sands = {"default:sand", "default:desert_sand", --[["default:desert_stone"]]}
|
2016-12-30 14:56:19 +01:00
|
|
|
local p2
|
2019-08-20 16:13:03 +02:00
|
|
|
local psand = {}
|
2016-12-30 14:56:19 +01:00
|
|
|
local sand
|
2019-08-20 16:13:03 +02:00
|
|
|
local cnt = 0
|
|
|
|
local cnt_min = 100
|
2016-12-30 14:56:19 +01:00
|
|
|
for s=1, #sands do
|
2019-08-20 16:13:03 +02:00
|
|
|
cnt = 0
|
2016-12-30 14:56:19 +01:00
|
|
|
sand = sands[s]
|
2019-08-20 16:13:03 +02:00
|
|
|
psand[s] = minetest.find_node_near(mpos, 25, sand)
|
|
|
|
while psand == nil and cnt < 5 do
|
2016-12-30 14:56:19 +01:00
|
|
|
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)}
|
2019-08-20 16:13:03 +02:00
|
|
|
psand[s] = minetest.find_node_near(mpos, 25, sand)
|
2016-12-30 14:56:19 +01:00
|
|
|
end
|
2019-08-20 16:13:03 +02:00
|
|
|
if psand[s] ~= nil then
|
|
|
|
if cnt < cnt_min then
|
|
|
|
cnt_min = cnt
|
|
|
|
p2 = psand[s]
|
|
|
|
end
|
2016-12-30 14:56:19 +01:00
|
|
|
end
|
2013-09-26 01:37:24 +02:00
|
|
|
end
|
2013-09-16 21:24:44 +02:00
|
|
|
if p2 == nil then return end
|
|
|
|
if p2.y < 0 then return end
|
|
|
|
|
|
|
|
local off = 0
|
2019-08-23 17:13:15 +02:00
|
|
|
local opos1 = {x=p2.x+PYRA_Wm,y=p2.y-1,z=p2.z+PYRA_Wm}
|
|
|
|
local opos2 = {x=p2.x+PYRA_Wm,y=p2.y-1,z=p2.z}
|
|
|
|
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+PYRA_Wm}
|
2013-10-01 14:37:40 +02:00
|
|
|
local opos1_n = minetest.get_node_or_nil(opos1)
|
|
|
|
local opos2_n = minetest.get_node_or_nil(opos2)
|
|
|
|
local opos3_n = minetest.get_node_or_nil(opos3)
|
|
|
|
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
2013-09-26 01:37:24 +02:00
|
|
|
p2 = ground(opos1, p2)
|
|
|
|
end
|
2013-10-01 14:37:40 +02:00
|
|
|
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
2013-09-26 01:37:24 +02:00
|
|
|
p2 = ground(opos2, p2)
|
|
|
|
end
|
2013-10-01 14:37:40 +02:00
|
|
|
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
2013-09-26 01:37:24 +02:00
|
|
|
p2 = ground(opos3, p2)
|
2013-09-16 21:24:44 +02:00
|
|
|
end
|
2013-10-01 14:37:40 +02:00
|
|
|
p2.y = p2.y - 3
|
2019-08-23 18:51:32 +02:00
|
|
|
p2 = limit(p2, maxp)
|
2013-09-16 21:24:44 +02:00
|
|
|
if p2.y < 0 then p2.y = 0 end
|
2016-12-30 14:56:19 +01:00
|
|
|
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or
|
|
|
|
minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or
|
|
|
|
minetest.find_node_near(p2, 52, {"default:sandstonebrick"}) ~= nil or
|
2019-08-19 17:40:33 +02:00
|
|
|
minetest.find_node_near(p2, 52, {"default:desert_sandstone_brick"}) ~= nil then
|
2016-12-30 14:22:38 +01:00
|
|
|
return
|
|
|
|
end
|
2019-08-20 16:13:03 +02:00
|
|
|
|
2016-12-30 14:22:38 +01:00
|
|
|
if math.random(0,10) > 7 then
|
|
|
|
return
|
|
|
|
end
|
2019-08-20 20:32:14 +02:00
|
|
|
if (mg_name == "v6" and sand == "default:desert_sand" and math.random(1, 2) == 1) then
|
2019-08-20 17:05:45 +02:00
|
|
|
sand = "default:sand"
|
|
|
|
end
|
2016-12-30 14:56:19 +01:00
|
|
|
if sand == "default:desert_sand" then
|
2019-08-20 17:05:45 +02:00
|
|
|
-- Desert sandstone pyramid
|
2019-08-23 18:51:32 +02:00
|
|
|
make(p2, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone")
|
2019-08-20 20:32:14 +02:00
|
|
|
elseif sand == "default:sand" then
|
2019-08-20 17:05:45 +02:00
|
|
|
-- Sandstone pyramid
|
2019-08-23 18:51:32 +02:00
|
|
|
make(p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone")
|
2019-08-20 20:32:14 +02:00
|
|
|
else
|
|
|
|
-- Desert stone pyramid
|
2019-08-23 18:51:32 +02:00
|
|
|
make(p2, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "default:desert_sand", "desert_stone")
|
2016-12-30 14:56:19 +01:00
|
|
|
end
|
2013-09-16 21:23:16 +02:00
|
|
|
end
|
2013-09-26 01:37:24 +02:00
|
|
|
end)
|
2016-11-10 16:48:52 +01:00
|
|
|
|
|
|
|
-- Add backwards-compability for nodes from the original pyramids mod
|
|
|
|
if minetest.get_modpath("pyramids") == nil then
|
|
|
|
-- Nodes
|
|
|
|
minetest.register_alias("pyramids:trap", "tsm_pyramids:trap")
|
|
|
|
minetest.register_alias("pyramids:trap_2", "tsm_pyramids:trap_2")
|
|
|
|
minetest.register_alias("pyramids:deco_stone1", "tsm_pyramids:deco_stone1")
|
|
|
|
minetest.register_alias("pyramids:deco_stone2", "tsm_pyramids:deco_stone2")
|
|
|
|
minetest.register_alias("pyramids:deco_stone3", "tsm_pyramids:deco_stone3")
|
|
|
|
minetest.register_alias("pyramids:spawner_mummy", "tsm_pyramids:spawner_mummy")
|
|
|
|
end
|
2019-08-20 00:27:25 +02:00
|
|
|
|
|
|
|
minetest.register_chatcommand("spawnpyramid", {
|
|
|
|
description = S("Generate a pyramid"),
|
2019-08-20 01:07:42 +02:00
|
|
|
params = S("[<room_type>]"),
|
2019-08-20 00:27:25 +02:00
|
|
|
privs = { server = true },
|
|
|
|
func = function(name, param)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if not player then
|
|
|
|
return false, S("No player.")
|
|
|
|
end
|
|
|
|
local pos = player:get_pos()
|
|
|
|
pos = vector.round(pos)
|
2019-08-23 13:00:35 +02:00
|
|
|
-- TODO: Enable desert stone pyramid
|
|
|
|
local s = math.random(1,2)
|
2019-08-20 01:07:42 +02:00
|
|
|
local r = tonumber(param)
|
|
|
|
local room_id
|
|
|
|
if r then
|
|
|
|
room_id = r
|
|
|
|
end
|
|
|
|
local ok, msg
|
2019-08-23 17:13:15 +02:00
|
|
|
pos = vector.add(pos, {x=-PYRA_Wh, y=-1, z=0})
|
2019-08-20 01:07:42 +02:00
|
|
|
if s == 1 then
|
2019-08-20 20:47:11 +02:00
|
|
|
-- Sandstone
|
2019-08-20 01:07:42 +02:00
|
|
|
ok, msg = make(pos, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone", room_id)
|
2019-08-20 20:16:11 +02:00
|
|
|
elseif s == 2 then
|
2019-08-20 20:47:11 +02:00
|
|
|
-- Desert sandstone
|
2019-08-20 20:16:11 +02:00
|
|
|
ok, msg = make(pos, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone", room_id)
|
2019-08-20 01:07:42 +02:00
|
|
|
else
|
2019-08-20 20:47:11 +02:00
|
|
|
-- Desert stone
|
2019-08-23 13:00:35 +02:00
|
|
|
-- XXX: Currently unused
|
2019-08-20 20:47:11 +02:00
|
|
|
ok, msg = make(pos, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "ignore", "desert_stone", room_id)
|
2019-08-20 01:07:42 +02:00
|
|
|
end
|
|
|
|
if ok then
|
|
|
|
return true, S("Pyramid generated at @1.", minetest.pos_to_string(pos))
|
2019-08-20 00:27:25 +02:00
|
|
|
else
|
2019-08-20 01:07:42 +02:00
|
|
|
return false, msg
|
2019-08-20 00:27:25 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
)
|