loot.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. dungeon_loot.registered_loot = {
  2. -- buckets
  3. {name = "bucket:bucket_empty", chance = 0.55},
  4. -- water in deserts/ice or above ground, lava otherwise
  5. {name = "bucket:bucket_water", chance = 0.45,
  6. types = {"sandstone", "desert", "ice"}},
  7. {name = "bucket:bucket_water", chance = 0.45, y = {0, 32768},
  8. types = {"normal"}},
  9. {name = "bucket:bucket_lava", chance = 0.45, y = {-32768, -1},
  10. types = {"normal"}},
  11. -- various items
  12. {name = "default:stick", chance = 0.6, count = {3, 6}},
  13. {name = "default:flint", chance = 0.4, count = {1, 3}},
  14. {name = "vessels:glass_fragments", chance = 0.35, count = {1, 4}},
  15. {name = "carts:rail", chance = 0.35, count = {1, 6}},
  16. -- farming / consumable
  17. {name = "farming:string", chance = 0.5, count = {1, 8}},
  18. {name = "farming:wheat", chance = 0.5, count = {2, 5}},
  19. {name = "default:apple", chance = 0.4, count = {1, 4}},
  20. {name = "farming:seed_cotton", chance = 0.4, count = {1, 4},
  21. types = {"normal"}},
  22. {name = "default:cactus", chance = 0.4, count = {1, 4},
  23. types = {"sandstone", "desert"}},
  24. -- minerals
  25. {name = "default:coal_lump", chance = 0.9, count = {1, 12}},
  26. {name = "default:gold_ingot", chance = 0.5},
  27. {name = "default:steel_ingot", chance = 0.4, count = {1, 6}},
  28. {name = "default:mese_crystal", chance = 0.1, count = {2, 3}},
  29. -- tools
  30. {name = "default:sword_wood", chance = 0.6},
  31. {name = "default:pick_stone", chance = 0.3},
  32. {name = "default:axe_diamond", chance = 0.05},
  33. -- natural materials
  34. {name = "default:sand", chance = 0.8, count = {4, 32}, y = {-64, 32768},
  35. types = {"normal"}},
  36. {name = "default:desert_sand", chance = 0.8, count = {4, 32}, y = {-64, 32768},
  37. types = {"sandstone"}},
  38. {name = "default:desert_cobble", chance = 0.8, count = {4, 32},
  39. types = {"desert"}},
  40. {name = "default:snow", chance = 0.8, count = {8, 64}, y = {-64, 32768},
  41. types = {"ice"}},
  42. {name = "default:dirt", chance = 0.6, count = {2, 16}, y = {-64, 32768},
  43. types = {"normal", "sandstone", "desert"}},
  44. {name = "default:obsidian", chance = 0.25, count = {1, 3}, y = {-32768, -512}},
  45. {name = "default:mese", chance = 0.15, y = {-32768, -512}},
  46. }
  47. function dungeon_loot.register(t)
  48. if t.name ~= nil then
  49. t = {t} -- single entry
  50. end
  51. for _, loot in ipairs(t) do
  52. table.insert(dungeon_loot.registered_loot, loot)
  53. end
  54. end
  55. function dungeon_loot._internal_get_loot(pos_y, dungeontype)
  56. -- filter by y pos and type
  57. local ret = {}
  58. for _, l in ipairs(dungeon_loot.registered_loot) do
  59. if l.y == nil or (pos_y >= l.y[1] and pos_y <= l.y[2]) then
  60. if l.types == nil or table.indexof(l.types, dungeontype) ~= -1 then
  61. table.insert(ret, l)
  62. end
  63. end
  64. end
  65. return ret
  66. end