Advertisement
Dudugz-Contistente

Untitled

Oct 24th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. ShamanObject = function()
  2. local this = {}
  3.  
  4. __init__=function()
  5. this.objects={}
  6. return this
  7. end
  8.  
  9. this.add=function(...)
  10. local id,type,x,y,angle,vx,vy,alpha,count = ...
  11.  
  12. if id==nil then return error('O id do objeto não pode ser nulo.') end
  13. if type==nil then type=0 end
  14. if x==nil then x=0 end
  15. if y == nil then y=0 end
  16. if angle == nil then angle=0 end
  17. if vx==nil then x=0 end
  18. if vy == nil then y=0 end
  19. if alpha==nil then x=false end
  20. if count == nil then count=1 end
  21.  
  22. if not this.objects[id] then this.objects[id]={spawneds={},objects={}} end
  23.  
  24. table.insert(this.objects[id].objects,{id=id,type=type,x=x,y=y,angle=angle,vx=vx,vy=vy,alpha=alpha,count=count})
  25.  
  26. return this
  27. end
  28.  
  29. this.remove=function(id)
  30. if id == nil or id == all then
  31. for _,id in pairs(this.objects) do
  32. for _,object in pairs(id.spawneds) do
  33. tfm.exec.removeObject(object)
  34. end
  35. end
  36.  
  37. this.objects={}
  38. else
  39.  
  40. for _,object in pairs(this.objects[id].spawneds) do
  41. tfm.exec.removeObject(object)
  42. end
  43.  
  44. this.objects[id]={spawneds={},objects={}}
  45. end
  46.  
  47. return this
  48. end
  49.  
  50. this.spawn=function(id)
  51. if id == nil or id == all then
  52. for _,id in pairs(this.objects) do
  53. for index,object in ipairs(id.objects) do
  54. for i=1,object.count do
  55. this.objects[object.id].spawneds[#this.objects[object.id].spawneds+1] = tfm.exec.addShamanObject(object.type,object.x,object.y)
  56. table.remove(this.objects[object.id].objects,index)
  57. end
  58. end
  59. end
  60. end
  61.  
  62. return this
  63. end
  64.  
  65. return __init__()
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement