Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. -- Classifications for actor resist/damage
  2. _M.classifications = {
  3.     unliving = {undead = true, construct = true, crystal = true},
  4.     unnatural = {demon = true, elemental = true, horror = true, construct = true, undead = true},
  5.     living = function(type) return not _M.classifications.unliving[type] end,
  6.     natural = function(type) return not _M.classifications.unnatural[type] end,}
  7.  
  8. --- Check if the actor is a certain type or in an arbitrary set of classifications
  9. -- @param string representing the classification to check
  10. -- @return whether the actor is in this classification
  11. function _M:checkClassification(type_str)
  12.     -- Living and Natural are defined as not being Unliving or not Unnatural
  13.     -- Thus, all actors are in one category or the other
  14.     if not act or not type_str or not act.type then return end
  15.     if act.type == type_str then return true end
  16.     local class = _M.classifications[type_str]
  17.     if _G.type(class) == 'function' then return class(type_str) end
  18.     return class[act.type]
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement