loot.lua 2.4 KB

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