rot.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. local ROTLOVE_PATH = (...) .. '.'
  2. local Class = require (ROTLOVE_PATH .. 'class')
  3. local ROT = Class:extend('ROT', {
  4. DEFAULT_WIDTH =80,
  5. DEFAULT_HEIGHT=24,
  6. DIRS= {FOUR={
  7. { 0,-1},
  8. { 1, 0},
  9. { 0, 1},
  10. {-1, 0}
  11. },
  12. EIGHT={
  13. { 0,-1},
  14. { 1,-1},
  15. { 1, 0},
  16. { 1, 1},
  17. { 0, 1},
  18. {-1, 1},
  19. {-1, 0},
  20. {-1,-1}
  21. }
  22. }
  23. })
  24. package.loaded[...] = ROT
  25. -- Concatenating assert function
  26. -- see http://lua.space/general/assert-usage-caveat
  27. function ROT.assert(pass, ...)
  28. if pass then
  29. return pass, ...
  30. elseif select('#', ...) > 0 then
  31. error(table.concat({...}), 2)
  32. else
  33. error('assertion failed!', 2)
  34. end
  35. end
  36. ROT.Class = Class
  37. ROT.RNG = require (ROTLOVE_PATH .. 'rng')
  38. -- bind a function to a class instance
  39. function Class:bind (func)
  40. return function (...) return func(self, ...) end
  41. end
  42. -- get/set RNG instance for a class
  43. -- used by maps, noise, dice, etc.
  44. Class._rng = ROT.RNG
  45. function Class:getRNG()
  46. return self._rng
  47. end
  48. function Class:setRNG(rng)
  49. self._rng = rng or ROT.RNG
  50. return self
  51. end
  52. require (ROTLOVE_PATH .. 'newFuncs')
  53. ROT.Type = {} -- collection types tuned for various use cases
  54. ROT.Type.PointSet = require (ROTLOVE_PATH .. 'type.pointSet')
  55. ROT.Type.Grid = require (ROTLOVE_PATH .. 'type.grid')
  56. ROT.Display = require (ROTLOVE_PATH .. 'display')
  57. ROT.StringGenerator = require (ROTLOVE_PATH .. 'stringGenerator')
  58. ROT.EventQueue = require (ROTLOVE_PATH .. 'eventQueue')
  59. ROT.Scheduler = require (ROTLOVE_PATH .. 'scheduler')
  60. ROT.Scheduler.Simple = require (ROTLOVE_PATH .. 'scheduler.simple')
  61. ROT.Scheduler.Speed = require (ROTLOVE_PATH .. 'scheduler.speed')
  62. ROT.Scheduler.Action = require (ROTLOVE_PATH .. 'scheduler.action')
  63. ROT.Engine = require (ROTLOVE_PATH .. 'engine')
  64. ROT.Map = require (ROTLOVE_PATH .. 'map')
  65. ROT.Map.Arena = require (ROTLOVE_PATH .. 'map.arena')
  66. ROT.Map.DividedMaze = require (ROTLOVE_PATH .. 'map.dividedMaze')
  67. ROT.Map.IceyMaze = require (ROTLOVE_PATH .. 'map.iceyMaze')
  68. ROT.Map.EllerMaze = require (ROTLOVE_PATH .. 'map.ellerMaze')
  69. ROT.Map.Cellular = require (ROTLOVE_PATH .. 'map.cellular')
  70. ROT.Map.Dungeon = require (ROTLOVE_PATH .. 'map.dungeon')
  71. ROT.Map.Feature = require (ROTLOVE_PATH .. 'map.feature')
  72. ROT.Map.Room = require (ROTLOVE_PATH .. 'map.room')
  73. ROT.Map.Corridor = require (ROTLOVE_PATH .. 'map.corridor')
  74. ROT.Map.Digger = require (ROTLOVE_PATH .. 'map.digger')
  75. ROT.Map.Uniform = require (ROTLOVE_PATH .. 'map.uniform')
  76. ROT.Map.Rogue = require (ROTLOVE_PATH .. 'map.rogue')
  77. ROT.Map.BrogueRoom = require (ROTLOVE_PATH .. 'map.brogueRoom')
  78. ROT.Map.Brogue = require (ROTLOVE_PATH .. 'map.brogue')
  79. ROT.Noise = require (ROTLOVE_PATH .. 'noise')
  80. ROT.Noise.Simplex = require (ROTLOVE_PATH .. 'noise.simplex')
  81. ROT.FOV = require (ROTLOVE_PATH .. 'fov')
  82. ROT.FOV.Precise = require (ROTLOVE_PATH .. 'fov.precise')
  83. ROT.FOV.Bresenham = require (ROTLOVE_PATH .. 'fov.bresenham')
  84. ROT.FOV.Recursive = require (ROTLOVE_PATH .. 'fov.recursive')
  85. ROT.Color = require (ROTLOVE_PATH .. 'color')
  86. ROT.Lighting = require (ROTLOVE_PATH .. 'lighting')
  87. ROT.Path = require (ROTLOVE_PATH .. 'path')
  88. ROT.Path.Dijkstra = require (ROTLOVE_PATH .. 'path.dijkstra')
  89. ROT.Path.DijkstraMap = require (ROTLOVE_PATH .. 'path.dijkstraMap')
  90. ROT.Path.AStar = require (ROTLOVE_PATH .. 'path.astar')
  91. ROT.Text = require (ROTLOVE_PATH .. 'text')
  92. return ROT