From fb6cbbea660dd208ce0b1b67555220e67ed01dab Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 20 Aug 2019 03:14:39 +0200 Subject: [PATCH] Put sand into chests in sand-flooded pyramids --- init.lua | 28 ++++++++++++++++++---------- room.lua | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index 310e3bc..f9d4a49 100644 --- a/init.lua +++ b/init.lua @@ -30,23 +30,31 @@ else table.insert(chest_stuff, {name="farming:apple", max = 3}) end -function tsm_pyramids.fill_chest(pos) +function tsm_pyramids.fill_chest(pos, stype, flood_sand) minetest.after(2, function() + local sand = "default:sand" + if stype == "desert" 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) - if math.random(1,10) < 7 then - return - end local stacks = {} - 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)}) + -- Fill with sand in sand-flooded pyramids + if flood_sand then + table.insert(stacks, {name=sand, count = math.random(1,40)}) + 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 end for s=1,#stacks do diff --git a/room.lua b/room.lua index b0e5329..938e50c 100644 --- a/room.lua +++ b/room.lua @@ -635,7 +635,7 @@ function tsm_pyramids.make_room(pos, stype, room_id) local filled = 0 while filled < 8 do for c=1, #chests do - tsm_pyramids.fill_chest(chests[c]) + tsm_pyramids.fill_chest(chests[c], stype, room.flood_sand ~= false) filled = filled + 1 end end