diff --git a/mods/hungry_games/init.lua b/mods/hungry_games/init.lua index d25a115..d96e801 100644 --- a/mods/hungry_games/init.lua +++ b/mods/hungry_games/init.lua @@ -61,30 +61,48 @@ random_chests.setrefill("database", 5) --Register a new item that can be spawned in random chests. [SAFE] --eg chest_item('default:torch', 4, 6) #has a 1 in 4 chance of spawning up to 6 torches. +--the last item is a group number/word which means if an item of that group number has already +--been spawned then don't add any more of those group types to the chest. --items chest_item('default:apple', 4, 5) chest_item('default:ladder', 8, 5) chest_item('default:torch', 4, 6) -chest_item('default:axe_wood', 10, 1) -chest_item('default:axe_stone', 15, 1) -chest_item('default:axe_steel', 20, 1) +chest_item('default:axe_wood', 10, 1, "axe") +chest_item('default:axe_stone', 15, 1, "axe") +chest_item('default:axe_steel', 20, 1, "axe") chest_item('throwing:arrow', 4, 10) chest_item('throwing:arrow_fire', 12, 6) -chest_item('throwing:bow_wood', 5, 1) -chest_item('throwing:bow_stone', 10, 1) -chest_item('throwing:bow_steel', 15, 1) -chest_item('bucket:bucket_lava', 20, 1) -chest_item('bucket:bucket_water', 20, 1) -chest_item('default:sword_wood', 10, 1) -chest_item('default:sword_stone', 15, 1) -chest_item('default:sword_steel', 20, 1) +chest_item('throwing:bow_wood', 5, 1, "bow") +chest_item('throwing:bow_stone', 10, 1, "bow") +chest_item('throwing:bow_steel', 15, 1, "bow") +chest_item('bucket:bucket_lava', 50, 1, "odd") +chest_item('bucket:bucket_water', 40, 1) +chest_item('default:sword_wood', 10, 1, "sword") +chest_item('default:sword_stone', 15, 1, "sword") +chest_item('default:sword_steel', 20, 1, "sword") chest_item('food:bread_slice', 3, 1) chest_item('food:bun', 5, 1) chest_item('food:bread', 10, 1) chest_item('food:apple_juice', 6, 2) -chest_item('food:cactus_juice', 8, 2) +chest_item('food:cactus_juice', 8, 2, "odd") chest_item('survival_thirst:water_glass', 4, 2) -chest_item('snow:snowball', 10, 99) +chest_item('snow:snowball', 10, 99, "odd") +chest_item('3d_armor:helmet_wood', 10, 1, "helmet") +chest_item('3d_armor:helmet_steel', 30, 1, "helmet") +chest_item('3d_armor:helmet_bronze', 20, 1, "helmet") +chest_item('3d_armor:chestplate_wood', 10, 1, "chestplate") +chest_item('3d_armor:chestplate_steel', 30, 1, "chestplate") +chest_item('3d_armor:chestplate_bronze', 20, 1, "chestplate") +chest_item('3d_armor:leggings_wood', 10, 1, "leggings") +chest_item('3d_armor:leggings_steel', 30, 1, "leggings") +chest_item('3d_armor:leggings_bronze', 20, 1, "leggings") +chest_item('3d_armor:shield_wood', 10, 1, "shield") +chest_item('3d_armor:shield_steel', 30, 1, "shield") +chest_item('3d_armor:shield_bronze', 20, 1, "shield") +chest_item('more_armor:helmet_mithril', 40, 1, "helmet") +chest_item('more_armor:chestplate_mithril', 40, 1, "chestplate") +chest_item('more_armor:leggings_mithril', 40, 1, "leggings") +chest_item('more_armor:shield_mithril', 40, 1, "shield") --crafting items chest_item('default:stick', 8, 10) chest_item('default:steel_ingot', 15, 3) @@ -92,3 +110,4 @@ chest_item('farming:string', 7, 3) chest_item('hungry_games:stones', 6, 3) chest_item('food:cup', 5, 2) chest_item('hungry_games:planks', 5, 3) + diff --git a/mods/random_chests/init.lua b/mods/random_chests/init.lua index d962b03..6964cfb 100644 --- a/mods/random_chests/init.lua +++ b/mods/random_chests/init.lua @@ -32,9 +32,13 @@ local fill_chest = function(pos) end --Spawn chest and add random items. local invcontent = {} + local used_groups = {} for i,v in pairs(random_items) do - if math.random(1, v[2]) == 1 then - table.insert(invcontent, v[1].." "..tostring(math.random(1,v[3])) ) + if not used_groups[v[4]] then + if math.random(1, v[2]) == 1 then + table.insert(invcontent, v[1].." "..tostring(math.random(1,v[3])) ) + if v[4] then used_groups[v[4]] = true end + end end end minetest.env:add_node(pos,{name='default:chest', inv=invcontent}) @@ -55,9 +59,9 @@ random_chests = {} --Register a new item that can be spawned in random chests. --eg random_chests.register_item('default:torch', 4, 6) #has a 1 in 4 chance of spawning up to 6 torches. -function random_chests.register_item(item, rarity, max) +function random_chests.register_item(item, rarity, max, group) assert(item and rarity and max) - table.insert(random_items, {item, rarity, max}) + table.insert(random_items, {item, rarity, max, group}) end --Set rarity of the chests. (n = How many per chunk).