Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
fbb674a01c | |||
|
ea6f428e7d | ||
|
7b281bec47 | ||
|
99349cc616 | ||
|
57adec6576 | ||
|
55f4a1f292 | ||
|
145a73188c |
|
@ -1,4 +1,5 @@
|
||||||
default
|
default
|
||||||
|
maptools
|
||||||
farming?
|
farming?
|
||||||
sandplus?
|
sandplus?
|
||||||
treasurer?
|
treasurer?
|
||||||
|
|
190
init.lua
190
init.lua
|
@ -1,4 +1,6 @@
|
||||||
pyramids = {}
|
pyramids = {}
|
||||||
|
pyramids.max_time = 60 * 30
|
||||||
|
local random = math.random
|
||||||
|
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
|
||||||
|
@ -16,31 +18,29 @@ local chest_stuff = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pyramids.fill_chest(pos)
|
function pyramids.fill_chest(pos)
|
||||||
minetest.after(2, function()
|
local n = minetest.get_node(pos)
|
||||||
local n = minetest.get_node(pos)
|
if n and n.name and n.name == "tsm_pyramids:chest" then
|
||||||
if n and n.name and n.name == "default:chest" then
|
local meta = minetest.get_meta(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local inv = meta:get_inventory()
|
||||||
local inv = meta:get_inventory()
|
inv:set_size("main", 8*4)
|
||||||
inv:set_size("main", 8*4)
|
inv:set_list("main", { [1] = "", [32] = "" })
|
||||||
if math.random(1,10) < 7 then return end
|
if random(1,10) < 7 then return end
|
||||||
local stacks = {}
|
local stacks = {}
|
||||||
if minetest.get_modpath("treasurer") ~= nil then
|
if minetest.get_modpath("treasurer") ~= nil then
|
||||||
stacks = treasurer.select_random_treasures(3,7,9,{"minetool", "food", "crafting_component"})
|
stacks = treasurer.select_random_treasures(3,1,5,{"armes", "armures", "precieux"})
|
||||||
else
|
else
|
||||||
for i=0,2,1 do
|
for i=0,2,1 do
|
||||||
local stuff = chest_stuff[math.random(1,#chest_stuff)]
|
local stuff = chest_stuff[random(1,#chest_stuff)]
|
||||||
if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then stuff = chest_stuff[1] end
|
if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then stuff = chest_stuff[1] end
|
||||||
table.insert(stacks, {name=stuff.name, count = math.random(1,stuff.max)})
|
table.insert(stacks, {name=stuff.name, count = random(1,stuff.max)})
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end)
|
for s=1,#stacks do
|
||||||
|
if not inv:contains_item("main", stacks[s]) then
|
||||||
|
inv:set_stack("main", random(1,32), stacks[s])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_spawner(pos)
|
local function add_spawner(pos)
|
||||||
|
@ -67,7 +67,7 @@ local function underground(pos, stone, sand)
|
||||||
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 break end
|
||||||
if cnt>math.random(2,4) then mat = stone end
|
if cnt>random(2,4) then mat = stone end
|
||||||
minetest.set_node(p2, {name=mat})
|
minetest.set_node(p2, {name=mat})
|
||||||
p2.y = p2.y-1
|
p2.y = p2.y-1
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ local function make(pos, brick, sandstone, stone, sand)
|
||||||
for iy=0,10,1 do
|
for iy=0,10,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 underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}, stone, sand) end
|
||||||
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name=brick})
|
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name=brick})
|
||||||
for yy=1,10-iy,1 do
|
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})
|
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
|
||||||
|
@ -133,74 +133,86 @@ local function ground(pos, old)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(
|
||||||
if maxp.y < 0 then return end
|
function(minp, maxp, seed)
|
||||||
math.randomseed(seed)
|
minetest.after(
|
||||||
local cnt = 0
|
3, function(minp, maxp, seed)
|
||||||
|
if maxp.y < 0 then return end
|
||||||
|
math.randomseed(seed)
|
||||||
|
local cnt = 0
|
||||||
|
|
||||||
local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
||||||
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
||||||
|
|
||||||
if noise1 > 0.25 or noise1 < -0.26 then
|
if noise1 > 0.75 or noise1 < -0.76 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=random(minp.x,maxp.x), y=random(minp.y,maxp.y), z=random(minp.z,maxp.z)}
|
||||||
|
|
||||||
local sands = {"default:desert_sand", "default:sand"}
|
local sands = {"default:desert_sand"}
|
||||||
local p2
|
local p2
|
||||||
local sand
|
local sand
|
||||||
for s=1, #sands do
|
for s=1, #sands do
|
||||||
sand = sands[s]
|
sand = sands[s]
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
p2 = minetest.find_node_near(mpos, 25, sand)
|
||||||
while p2 == nil and cnt < 5 do
|
while p2 == 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=random(minp.x,maxp.x), y=random(minp.y,maxp.y), z=random(minp.z,maxp.z)}
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
p2 = minetest.find_node_near(mpos, 25, sand)
|
||||||
end
|
end
|
||||||
if p2 ~= nil then
|
if p2 ~= nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if p2 == nil then return end
|
if p2 == nil then return end
|
||||||
if p2.y < 0 then return end
|
if p2.y < 0 then return end
|
||||||
|
|
||||||
local off = 0
|
local off = 0
|
||||||
local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
|
local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
|
||||||
local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
|
local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
|
||||||
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
|
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
|
||||||
local opos1_n = minetest.get_node_or_nil(opos1)
|
local opos1_n = minetest.get_node_or_nil(opos1)
|
||||||
local opos2_n = minetest.get_node_or_nil(opos2)
|
local opos2_n = minetest.get_node_or_nil(opos2)
|
||||||
local opos3_n = minetest.get_node_or_nil(opos3)
|
local opos3_n = minetest.get_node_or_nil(opos3)
|
||||||
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
||||||
p2 = ground(opos1, p2)
|
p2 = ground(opos1, p2)
|
||||||
end
|
end
|
||||||
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
||||||
p2 = ground(opos2, p2)
|
p2 = ground(opos2, p2)
|
||||||
end
|
end
|
||||||
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
||||||
p2 = ground(opos3, p2)
|
p2 = ground(opos3, p2)
|
||||||
end
|
end
|
||||||
p2.y = p2.y - 3
|
p2.y = p2.y - 3
|
||||||
if p2.y < 0 then p2.y = 0 end
|
if p2.y < 0 then p2.y = 0 end
|
||||||
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or
|
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, 22, {"default:dirt_with_grass"}) ~= nil or
|
||||||
minetest.find_node_near(p2, 52, {"default:sandstonebrick"}) ~= nil or
|
minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil or
|
||||||
minetest.find_node_near(p2, 52, {"sandplus:desert_sandstonebrick"}) ~= nil then
|
minetest.find_node_near(p2, 52, {"maptools:desert_sandstone_brick"}) ~= nil or
|
||||||
return
|
minetest.find_node_near(p2, 52, {"maptools:silver_sandstone_brick"}) ~= nil or
|
||||||
end
|
minetest.find_node_near(p2, 52, {"sandplus:desert_sandstonebrick"}) ~= nil
|
||||||
|
then return end
|
||||||
|
|
||||||
if math.random(0,10) > 7 then
|
if random(0,10) > 7 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if sand == "default:desert_sand" then
|
local p_type = random(1, 3)
|
||||||
if minetest.get_modpath("sandplus") then
|
local p_pot = {
|
||||||
minetest.after(0.8, make, p2, "sandplus:desert_sandstonebrick", "sandplus:desert_sandstone", "default:desert_stone", "default:desert_sand")
|
[1] = {"maptools:sandstone_brick", "default:sandstone", "default:sandstone", "default:sand"},
|
||||||
else
|
[2] = {"maptools:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand"},
|
||||||
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:desert_stone", "default:desert_sand")
|
[3] = {"maptools:silver_sandstone_brick", "default:silver_sandstone", "default:silver_sandstone", "default:silver_sand"}
|
||||||
end
|
}
|
||||||
else
|
|
||||||
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand")
|
if sand == "default:desert_sand" then
|
||||||
end
|
if minetest.get_modpath("sandplus") then
|
||||||
end
|
minetest.after(0.8, make, p2, "sandplus:desert_sandstonebrick", "sandplus:desert_sandstone", "default:desert_stone", "default:desert_sand")
|
||||||
end)
|
else
|
||||||
|
minetest.after(0.8, make, p2, p_pot[p_type][1], p_pot[p_type][2], p_pot[p_type][3], p_pot[p_type][4])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, minp, maxp, seed)
|
||||||
|
end)
|
||||||
|
|
||||||
-- Add backwards-compability for nodes from the original pyramids mod
|
-- Add backwards-compability for nodes from the original pyramids mod
|
||||||
if minetest.get_modpath("pyramids") == nil then
|
if minetest.get_modpath("pyramids") == nil then
|
||||||
|
@ -215,3 +227,5 @@ if minetest.get_modpath("pyramids") == nil then
|
||||||
-- FIXME: Entities are currently NOT backwards-compatible
|
-- FIXME: Entities are currently NOT backwards-compatible
|
||||||
-- TODO: Update README when full backwards-compability is achieved
|
-- TODO: Update README when full backwards-compability is achieved
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.log("action", "[tsm_pyramids] loaded.")
|
||||||
|
|
54
nodes.lua
54
nodes.lua
|
@ -20,7 +20,7 @@ for i=1,3 do
|
||||||
_doc_items_longdesc = decodesc,
|
_doc_items_longdesc = decodesc,
|
||||||
tiles = {"default_sandstone.png", "default_sandstone.png", "default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
tiles = {"default_sandstone.png", "default_sandstone.png", "default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = minetest.registered_nodes["default:sandstone"].groups,
|
groups = {unbreakable=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@ local trap_on_timer = function (pos, elapsed)
|
||||||
if n and n.name then
|
if n and n.name then
|
||||||
if minetest.registered_nodes[n.name]._tsm_pyramids_crack and minetest.registered_nodes[n.name]._tsm_pyramids_crack < 2 then
|
if minetest.registered_nodes[n.name]._tsm_pyramids_crack and minetest.registered_nodes[n.name]._tsm_pyramids_crack < 2 then
|
||||||
minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
|
minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
|
||||||
nodeupdate(pos)
|
minetest.check_for_falling(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,3 +65,53 @@ minetest.register_node("tsm_pyramids:trap_2", {
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
drop = "",
|
drop = "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local function get_chest_formspec(pos)
|
||||||
|
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||||
|
local formspec =
|
||||||
|
"size[8,9]" ..
|
||||||
|
default.gui_bg ..
|
||||||
|
default.gui_bg_img ..
|
||||||
|
default.gui_slots ..
|
||||||
|
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
|
||||||
|
"list[current_player;main;0,4.85;8,1;]" ..
|
||||||
|
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||||
|
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
return formspec
|
||||||
|
end
|
||||||
|
|
||||||
|
local chestdef = minetest.registered_nodes["default:chest"]
|
||||||
|
minetest.register_node(
|
||||||
|
"tsm_pyramids:chest", {
|
||||||
|
description = "tsm_pyramids Chest auto refilled",
|
||||||
|
tiles = chestdef.tiles,
|
||||||
|
stack_max = 1000,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
on_construct = function(pos)
|
||||||
|
chestdef.on_construct(pos)
|
||||||
|
minetest.get_node_timer(pos):start(pyramids.max_time)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
end,
|
||||||
|
on_metadata_inventory_move = chestdef.on_metadata_inventory_move,
|
||||||
|
on_metadata_inventory_put = chestdef.on_metadata_inventory_put,
|
||||||
|
on_metadata_inventory_take = chestdef.on_metadata_inventory_take,
|
||||||
|
groups = {unbreakable = 1, not_in_creative_inventory = 1},
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
pyramids.fill_chest(pos)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
if not default.can_interact_with_node(clicker, pos) then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.after(
|
||||||
|
0.2,
|
||||||
|
minetest.show_formspec,
|
||||||
|
clicker:get_player_name(),
|
||||||
|
"default:chest", get_chest_formspec(pos))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
5
room.lua
5
room.lua
|
@ -35,6 +35,8 @@ local function replace(str,iy)
|
||||||
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
|
||||||
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
|
||||||
if str == "a" then out = "" end
|
if str == "a" then out = "" end
|
||||||
|
if str == "c" then out = "tsm_pyramids:" end
|
||||||
|
if str == "s" then out = "maptools:" end
|
||||||
return out..code[str]
|
return out..code[str]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,8 +44,8 @@ local function replace2(str,iy)
|
||||||
local out = "default:"
|
local out = "default:"
|
||||||
if iy == 0 and str == "l" then out = "tsm_pyramids:" str = "t"
|
if iy == 0 and str == "l" then out = "tsm_pyramids:" str = "t"
|
||||||
elseif iy < 3 and str == "l" then str = "a" end
|
elseif iy < 3 and str == "l" then str = "a" end
|
||||||
|
|
||||||
if str == "a" then out = "" end
|
if str == "a" then out = "" end
|
||||||
|
if str == "b" then out = "maptools:" end
|
||||||
return out..code[str]
|
return out..code[str]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,7 +58,6 @@ function pyramids.make_room(pos)
|
||||||
local p2 = 0
|
local p2 = 0
|
||||||
if n_str == "c" then
|
if n_str == "c" then
|
||||||
if ix < 3 then p2 = 1 else p2 = 3 end
|
if ix < 3 then p2 = 1 else p2 = 3 end
|
||||||
pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
|
|
||||||
end
|
end
|
||||||
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
|
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user