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
15
init.lua
15
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,12 +18,12 @@ 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 == "default:chest" then
|
if n and n.name and n.name == "tsm_pyramids: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
|
||||||
@ -39,9 +40,7 @@ function pyramids.fill_chest(pos)
|
|||||||
inv:set_stack("main", random(1,32), stacks[s])
|
inv:set_stack("main", random(1,32), stacks[s])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_spawner(pos)
|
local function add_spawner(pos)
|
||||||
@ -134,7 +133,10 @@ local function ground(pos, old)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(
|
||||||
|
function(minp, maxp, seed)
|
||||||
|
minetest.after(
|
||||||
|
3, 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
|
local cnt = 0
|
||||||
@ -209,7 +211,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand")
|
minetest.after(0.8, make, p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand")
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
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