Guest User

Untitled

a guest
Oct 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. mvid={}
  2. mvrx={}
  3. mvry={}
  4.  
  5. rindex=0
  6.  
  7. -- getTypeEx, by devast8a
  8. function getTypeEx(gtex, gtey)
  9. gter = 0
  10. function getTypeExInner()
  11. if tpt.get_property("x", gtex, gtey) == gtex and tpt.get_property("y", gtex, gtey) == gtey then
  12. gter = tpt.get_property("type" ,gtex , gtey)
  13. end
  14. end
  15.  
  16. if pcall(getTypeExInner) then
  17. return gter
  18. else
  19. return 0
  20. end
  21. end
  22.  
  23. function updatevars()
  24. x = tpt.get_property("x", centerpt)
  25. y = tpt.get_property("y", centerpt)
  26. end
  27.  
  28. function particles()
  29. updatevars()
  30. add_particle(x,y)
  31. if rindex > 0 then
  32. for tmpid = 1, rindex, 1 do
  33. add_particle(x - mvrx[tmpid], y - mvry[tmpid])
  34. tpt.set_property("x", x - mvrx[tmpid], mvid[tmpid])
  35. tpt.set_property("y", y - mvry[tmpid], mvid[tmpid])
  36. end
  37. end
  38. end
  39.  
  40. function add_particle(CDx, CDy)
  41. if tpt.get_property("type", CDx, CDy - 1) == 1 then add_particle_sub(CDx, CDy - 1) end
  42. if tpt.get_property("type", CDx + 1, CDy - 1) == 1 then add_particle_sub(CDx + 1, CDy - 1) end
  43. if tpt.get_property("type", CDx + 1, CDy) == 1 then add_particle_sub(CDx + 1, CDy) end
  44. if tpt.get_property("type", CDx + 1, CDy + 1) == 1 then add_particle_sub(CDx + 1, CDy + 1) end
  45. if tpt.get_property("type", CDx, CDy + 1) == 1 then add_particle_sub(CDx, CDy + 1) end
  46. if tpt.get_property("type", CDx - 1, CDy + 1) == 1 then add_particle_sub(CDx - 1, CDy + 1) end
  47. if tpt.get_property("type", CDx - 1, CDy) == 1 then add_particle_sub(CDx - 1, CDy) end
  48. if tpt.get_property("type", CDx - 1, CDy - 1) == 1 then add_particle_sub(CDx - 1, CDy - 1) end
  49. tpt.drawpixel(CDx, CDy, 0, 192, 127)
  50. end
  51.  
  52. function add_particle_sub(apx, apy)
  53. rindex = rindex + 1
  54. tpt.delete(apx, apy)
  55. mvid[rindex] = tpt.create(apx, apy, "grav")
  56. mvrx[rindex] = x - apx
  57. mvry[rindex] = y - apy
  58. end
  59.  
  60. function reset_moving()
  61. if rindex > 0 then
  62. for tmpid = 1, rindex, 1 do
  63. tpt.delete(tmpid)
  64. end
  65. rindex = 0
  66. end
  67. tpt.unregister_step(particles)
  68. tpt.register_mouseevent(click)
  69. end
  70.  
  71. function click(x, y)
  72. if tpt.get_property("type",x, y) == 1 then
  73. tpt.delete(x, y)
  74. -- Setting up
  75. centerpt = tpt.create(x, y, "grav")
  76.  
  77. mvid={}
  78. mvrx={}
  79. mvry={}
  80.  
  81. rindex=0
  82. updatevars()
  83. -- Setup Complete!
  84. tpt.register_step(particles)
  85. tpt.unregister_mouseevent(click)
  86. end
  87. end
  88.  
  89. tpt.register_mouseevent(click)
Add Comment
Please, Sign In to add comment