mirror of
http://repo.or.cz/minetest_pyramids/tsm_pyramids.git
synced 2024-11-10 12:00:17 +01:00
Drop a minetest.after
This commit is contained in:
parent
e3a6dac028
commit
76bd636df2
57
init.lua
57
init.lua
|
@ -40,40 +40,37 @@ else
|
|||
end
|
||||
|
||||
function tsm_pyramids.fill_chest(pos, stype, flood_sand)
|
||||
minetest.after(2, function()
|
||||
local sand = "default:sand"
|
||||
if stype == "desert_sandstone" or stype == "desert_stone" then
|
||||
sand = "default:desert_sand"
|
||||
local sand = "default:sand"
|
||||
if stype == "desert_sandstone" or stype == "desert_stone" then
|
||||
sand = "default:desert_sand"
|
||||
end
|
||||
local n = minetest.get_node(pos)
|
||||
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)
|
||||
local stacks = {}
|
||||
-- Fill with sand in sand-flooded pyramids
|
||||
if flood_sand then
|
||||
table.insert(stacks, {name=sand, count = math.random(1,32)})
|
||||
end
|
||||
local n = minetest.get_node(pos)
|
||||
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)
|
||||
local stacks = {}
|
||||
-- Fill with sand in sand-flooded pyramids
|
||||
if flood_sand then
|
||||
table.insert(stacks, {name=sand, count = math.random(1,32)})
|
||||
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
|
||||
-- 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
|
||||
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)
|
||||
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
|
||||
|
||||
local function add_spawner(pos, mummy_offset)
|
||||
|
|
Loading…
Reference in New Issue
Block a user