init.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- "Dungeon Loot" [dungeon_loot]
  2. -- Copyright (c) 2015 BlockMen <blockmen2015@gmail.com>
  3. --
  4. -- init.lua
  5. --
  6. -- This software is provided 'as-is', without any express or implied warranty. In no
  7. -- event will the authors be held liable for any damages arising from the use of
  8. -- this software.
  9. --
  10. -- Permission is granted to anyone to use this software for any purpose, including
  11. -- commercial applications, and to alter it and redistribute it freely, subject to the
  12. -- following restrictions:
  13. --
  14. -- 1. The origin of this software must not be misrepresented; you must not
  15. -- claim that you wrote the original software. If you use this software in a
  16. -- product, an acknowledgment in the product documentation is required.
  17. -- 2. Altered source versions must be plainly marked as such, and must not
  18. -- be misrepresented as being the original software.
  19. -- 3. This notice may not be removed or altered from any source distribution.
  20. --
  21. -- Following Code (everything before fill_chest) by Amoeba <amoeba@iki.fi>
  22. dungeon_loot = {}
  23. dungeon_loot.version = 1.2
  24. -- Load other file(s)
  25. local modpath = minetest.get_modpath("dungeon_loot")
  26. dofile(modpath .. "/config.lua") -- All the constants for simple tuning
  27. dofile(modpath .. "/oerkki.lua")
  28. dofile(modpath .. "/loot.lua")
  29. minetest.set_gen_notify("dungeon")
  30. minetest.register_on_generated(function(minp, maxp, blockseed)
  31. local ntf = minetest.get_mapgen_object("gennotify")
  32. if ntf and ntf.dungeon and #ntf.dungeon >= dungeon_loot.min_num_of_rooms then
  33. -- Have to copy the table, because 'place_spawner' modifies it.
  34. minetest.after(3, dungeon_loot.place_loot_chest, table.copy(ntf.dungeon))
  35. minetest.after(3, dungeon_loot.place_oerkki_stones, table.copy(ntf.dungeon))
  36. end
  37. end)