2
0

loot.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. -- Loot from the `default` mod is registered here,
  2. -- with the rest being registered in the respective mods
  3. dungeon_loot.registered_loot = {
  4. -- various items
  5. {name = "default:stick", chance = 0.6, count = {3, 6}},
  6. {name = "default:flint", chance = 0.4, count = {1, 3}},
  7. -- farming / consumable
  8. {name = "default:apple", chance = 0.4, count = {1, 4}},
  9. {name = "default:cactus", chance = 0.4, count = {1, 4},
  10. types = {"sandstone", "desert"}},
  11. -- minerals
  12. {name = "default:coal_lump", chance = 0.9, count = {1, 12}},
  13. {name = "default:gold_ingot", chance = 0.5},
  14. {name = "default:steel_ingot", chance = 0.4, count = {1, 6}},
  15. {name = "default:mese_crystal", chance = 0.1, count = {2, 3}},
  16. -- tools
  17. {name = "default:sword_wood", chance = 0.6},
  18. {name = "default:pick_stone", chance = 0.3},
  19. {name = "default:axe_diamond", chance = 0.05},
  20. -- natural materials
  21. {name = "default:sand", chance = 0.8, count = {4, 32}, y = {-64, 32768},
  22. types = {"normal"}},
  23. {name = "default:desert_sand", chance = 0.8, count = {4, 32}, y = {-64, 32768},
  24. types = {"sandstone"}},
  25. {name = "default:desert_cobble", chance = 0.8, count = {4, 32},
  26. types = {"desert"}},
  27. {name = "default:snow", chance = 0.8, count = {8, 64}, y = {-64, 32768},
  28. types = {"ice"}},
  29. {name = "default:dirt", chance = 0.6, count = {2, 16}, y = {-64, 32768},
  30. types = {"normal", "sandstone", "desert"}},
  31. {name = "default:obsidian", chance = 0.25, count = {1, 3}, y = {-32768, -512}},
  32. {name = "default:mese", chance = 0.15, y = {-32768, -512}},
  33. }
  34. function dungeon_loot.register(t)
  35. if t.name ~= nil then
  36. t = {t} -- single entry
  37. end
  38. for _, loot in ipairs(t) do
  39. table.insert(dungeon_loot.registered_loot, loot)
  40. end
  41. end
  42. function dungeon_loot._internal_get_loot(pos_y, dungeontype)
  43. -- filter by y pos and type
  44. local ret = {}
  45. for _, l in ipairs(dungeon_loot.registered_loot) do
  46. if l.y == nil or (pos_y >= l.y[1] and pos_y <= l.y[2]) then
  47. if l.types == nil or table.indexof(l.types, dungeontype) ~= -1 then
  48. table.insert(ret, l)
  49. end
  50. end
  51. end
  52. return ret
  53. end