Ajout de la régénération des items toutes les 30 minutes
- Les coffres deviennent indestructibles - Ajout d'un timer de 30 minutes pour le régénération des items
This commit is contained in:
parent
99349cc616
commit
7b281bec47
199
init.lua
199
init.lua
@ -1,4 +1,5 @@
|
|||||||
pyramids = {}
|
pyramids = {}
|
||||||
|
pyramids.max_time = 60 * 30
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
|
||||||
@ -17,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 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,1,5,{"armes", "armures", "precieux"})
|
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[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 = 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", 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)
|
||||||
@ -134,82 +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 noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
||||||
|
|
||||||
|
if noise1 > 0.25 or noise1 < -0.26 then
|
||||||
|
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"}
|
||||||
|
local p2
|
||||||
|
local sand
|
||||||
|
for s=1, #sands do
|
||||||
|
sand = sands[s]
|
||||||
|
p2 = minetest.find_node_near(mpos, 25, sand)
|
||||||
|
while p2 == nil and cnt < 5 do
|
||||||
|
cnt = cnt+1
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
if p2 ~= nil then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if p2 == nil then return end
|
||||||
|
if p2.y < 0 then return end
|
||||||
|
|
||||||
local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
|
local off = 0
|
||||||
local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
|
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}
|
||||||
if noise1 > 0.25 or noise1 < -0.26 then
|
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
|
||||||
local mpos = {x=random(minp.x,maxp.x), y=random(minp.y,maxp.y), z=random(minp.z,maxp.z)}
|
local opos1_n = minetest.get_node_or_nil(opos1)
|
||||||
|
local opos2_n = minetest.get_node_or_nil(opos2)
|
||||||
local sands = {"default:desert_sand"}
|
local opos3_n = minetest.get_node_or_nil(opos3)
|
||||||
local p2
|
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
||||||
local sand
|
p2 = ground(opos1, p2)
|
||||||
for s=1, #sands do
|
end
|
||||||
sand = sands[s]
|
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
p2 = ground(opos2, p2)
|
||||||
while p2 == nil and cnt < 5 do
|
end
|
||||||
cnt = cnt+1
|
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
||||||
mpos = {x=random(minp.x,maxp.x), y=random(minp.y,maxp.y), z=random(minp.z,maxp.z)}
|
p2 = ground(opos3, p2)
|
||||||
p2 = minetest.find_node_near(mpos, 25, sand)
|
end
|
||||||
end
|
p2.y = p2.y - 3
|
||||||
if p2 ~= nil then
|
if p2.y < 0 then p2.y = 0 end
|
||||||
break
|
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or
|
||||||
end
|
minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or
|
||||||
end
|
minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil or
|
||||||
if p2 == nil then return end
|
minetest.find_node_near(p2, 52, {"maptools:desert_sandstone_brick"}) ~= nil or
|
||||||
if p2.y < 0 then return end
|
minetest.find_node_near(p2, 52, {"maptools:silver_sandstone_brick"}) ~= nil or
|
||||||
|
minetest.find_node_near(p2, 52, {"sandplus:desert_sandstonebrick"}) ~= nil
|
||||||
local off = 0
|
then return end
|
||||||
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}
|
if random(0,10) > 7 then
|
||||||
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
|
return
|
||||||
local opos1_n = minetest.get_node_or_nil(opos1)
|
end
|
||||||
local opos2_n = minetest.get_node_or_nil(opos2)
|
local p_type = random(1, 3)
|
||||||
local opos3_n = minetest.get_node_or_nil(opos3)
|
local p_pot = {
|
||||||
if opos1_n and opos1_n.name and opos1_n.name == "air" then
|
[1] = {"maptools:sandstone_brick", "default:sandstone", "default:sandstone", "default:sand"},
|
||||||
p2 = ground(opos1, p2)
|
[2] = {"maptools:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand"},
|
||||||
end
|
[3] = {"maptools:silver_sandstone_brick", "default:silver_sandstone", "default:silver_sandstone", "default:silver_sand"}
|
||||||
if opos2_n and opos2_n.name and opos2_n.name == "air" then
|
}
|
||||||
p2 = ground(opos2, p2)
|
|
||||||
end
|
if sand == "default:desert_sand" then
|
||||||
if opos3_n and opos3_n.name and opos3_n.name == "air" then
|
if minetest.get_modpath("sandplus") then
|
||||||
p2 = ground(opos3, p2)
|
minetest.after(0.8, make, p2, "sandplus:desert_sandstonebrick", "sandplus:desert_sandstone", "default:desert_stone", "default:desert_sand")
|
||||||
end
|
else
|
||||||
p2.y = p2.y - 3
|
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])
|
||||||
if p2.y < 0 then p2.y = 0 end
|
end
|
||||||
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or
|
else
|
||||||
minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or
|
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand")
|
||||||
minetest.find_node_near(p2, 52, {"maptools:sandstone_brick"}) ~= nil or
|
end
|
||||||
minetest.find_node_near(p2, 52, {"maptools:desert_sandstone_brick"}) ~= nil or
|
end
|
||||||
minetest.find_node_near(p2, 52, {"maptools:silver_sandstone_brick"}) ~= nil or
|
end, minp, maxp, seed)
|
||||||
minetest.find_node_near(p2, 52, {"sandplus:desert_sandstonebrick"}) ~= nil
|
end)
|
||||||
then return end
|
|
||||||
|
|
||||||
if random(0,10) > 7 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local p_type = random(1, 3)
|
|
||||||
local p_pot = {
|
|
||||||
[1] = {"maptools:sandstone_brick", "default:sandstone", "default:sandstone", "default:sand"},
|
|
||||||
[2] = {"maptools:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand"},
|
|
||||||
[3] = {"maptools:silver_sandstone_brick", "default:silver_sandstone", "default:silver_sandstone", "default:silver_sand"}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sand == "default:desert_sand" then
|
|
||||||
if minetest.get_modpath("sandplus") then
|
|
||||||
minetest.after(0.8, make, p2, "sandplus:desert_sandstonebrick", "sandplus:desert_sandstone", "default:desert_stone", "default:desert_sand")
|
|
||||||
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)
|
|
||||||
|
|
||||||
-- 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
|
||||||
|
50
nodes.lua
50
nodes.lua
@ -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,
|
||||||
|
})
|
||||||
|
2
room.lua
2
room.lua
@ -35,6 +35,7 @@ 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
|
if str == "s" then out = "maptools:" end
|
||||||
return out..code[str]
|
return out..code[str]
|
||||||
end
|
end
|
||||||
@ -57,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…
x
Reference in New Issue
Block a user