Advertisement
electronic_steve

#tptscripts AI particles 2

Apr 29th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.86 KB | None | 0 0
  1. local stop = true
  2. function AI(i, x, y, s, n)
  3. local type = tpt.get_property("type",i)
  4. -- движение к цели
  5. if drawx == nil or drawy == nil then
  6. tpt.set_property("vx",0,i)
  7. tpt.set_property("vy",0,i)
  8. else
  9. if x < drawx and tpt.get_property("vx",i) then
  10. tpt.set_property("vx",1,i)
  11. end
  12. if x > drawx and tpt.get_property("vx",i) then
  13. tpt.set_property("vx",-1,i)
  14. end
  15.  
  16.  
  17. if y < drawy and tpt.get_property("vy",i) then
  18. tpt.set_property("vy",1,i)
  19. end
  20. if y > drawy and tpt.get_property("vy",i) then
  21. tpt.set_property("vy",-1,i)
  22. end
  23.  
  24.  
  25. if element== "" or element== "delete" or element=="not" then
  26. -- отправка ботов
  27. if element=="" then
  28. if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
  29. if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
  30. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
  31. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
  32.  
  33. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  34. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  35. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  36. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  37.  
  38. if stop ==true then if y == drawy and x==drawx then tpt.delete(i) reset(x,y,i) local stop = true end end
  39. end
  40.  
  41. --удаление элемента
  42.  
  43. if element=="delete" then
  44. if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(x-1,y) tpt.delete(i) reset(x,y,i) local stop = false end end
  45. if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(x+1,y) tpt.delete(i) reset(x,y,i) local stop = false end end
  46. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(x,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  47. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(x,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  48.  
  49. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.delete(x-1,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  50. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.delete(x+1,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  51. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.delete(x-1,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  52. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.delete(x+1,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  53.  
  54. if stop ==true then if y == drawy and x==drawx then tpt.delete(x,y) tpt.delete(i) reset(x,y,i) local stop = true end end
  55. end
  56. --не удалять точку
  57.  
  58. if element=="not" then
  59. if stop ==true then if x == drawx+1 and y==drawy then local stop = false end end
  60. if stop ==true then if x == drawx-1 and y==drawy then local stop = false end end
  61. if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
  62. if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
  63.  
  64. if stop ==true then if x == drawx+1 and y==drawy+1 then local stop = false end end
  65. if stop ==true then if x == drawx-1 and y==drawy-1 then local stop = false end end
  66. if stop ==true then if y == drawy+1 and x==drawx+1 then local stop = false end end
  67. if stop ==true then if y == drawy+1 and x==drawx-1 then local stop = false end end
  68.  
  69. if stop ==true then if y == drawy and x==drawx then local stop = true end end
  70. end
  71.  
  72.  
  73. --установка элемента
  74. else
  75. if stop ==true then if x == drawx+1 and y==drawy then tpt.create(x-1,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  76. if stop ==true then if x == drawx-1 and y==drawy then tpt.create(x+1,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  77. if stop ==true then if y == drawy+1 and x==drawx then tpt.create(x,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  78. if stop ==true then if y == drawy-1 and x==drawx then tpt.create(x,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  79.  
  80. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.create(x-1,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  81. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.create(x+1,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  82. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.create(x+1,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  83. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.create(x-1,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  84.  
  85. if stop ==true then if y == drawy and x==drawx then tpt.create(x,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = true end end
  86. end
  87. if stop == false then stop = true end
  88.  
  89. end
  90.  
  91. end
  92.  
  93. function AI2(i, x, y, s, n)
  94. local type = tpt.get_property("type",i)
  95.  
  96. -- движение к цели
  97. if drawx == nil or drawy == nil then
  98. tpt.set_property("vx",0,i)
  99. tpt.set_property("vy",0,i)
  100. else
  101. if x < drawx and tpt.get_property("vx",i) then
  102. tpt.set_property("vx",1,i)
  103. end
  104. if x > drawx and tpt.get_property("vx",i) then
  105. tpt.set_property("vx",-1,i)
  106. end
  107.  
  108.  
  109. if y < drawy and tpt.get_property("vy",i) then
  110. tpt.set_property("vy",1,i)
  111. end
  112. if y > drawy and tpt.get_property("vy",i) then
  113. tpt.set_property("vy",-1,i)
  114. end
  115.  
  116.  
  117. if element== "" or element== "delete" or element=="not" then
  118. -- отправка ботов
  119. if element=="" then
  120. if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
  121. if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
  122. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
  123. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
  124.  
  125. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  126. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  127. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  128. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.delete(i) reset(x,y,i) local stop = false end end
  129.  
  130. if stop ==true then if y == drawy and x==drawx then tpt.delete(i) reset(x,y,i) local stop = true end end
  131. end
  132.  
  133.  
  134. --удаление элемента
  135.  
  136. if element=="delete" then
  137. if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(x-1,y) tpt.delete(i) reset(x,y,i) local stop = false end end
  138. if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(x+1,y) tpt.delete(i) reset(x,y,i) local stop = false end end
  139. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(x,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  140. if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(x,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  141.  
  142. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.delete(x-1,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  143. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.delete(x+1,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  144. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.delete(x-1,y+1) tpt.delete(i) reset(x,y,i) local stop = false end end
  145. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.delete(x+1,y-1) tpt.delete(i) reset(x,y,i) local stop = false end end
  146.  
  147. if stop ==true then if y == drawy and x==drawx then tpt.delete(x,y) tpt.delete(i) reset(x,y,i) local stop = true end end
  148. end
  149. --не удалять точку
  150.  
  151. if element=="not" then
  152. if stop ==true then if x == drawx+1 and y==drawy then local stop = false end end
  153. if stop ==true then if x == drawx-1 and y==drawy then local stop = false end end
  154. if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
  155. if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
  156.  
  157. if stop ==true then if x == drawx+1 and y==drawy+1 then local stop = false end end
  158. if stop ==true then if x == drawx-1 and y==drawy-1 then local stop = false end end
  159. if stop ==true then if y == drawy+1 and x==drawx+1 then local stop = false end end
  160. if stop ==true then if y == drawy+1 and x==drawx-1 then local stop = false end end
  161.  
  162. if stop ==true then if y == drawy and x==drawx then local stop = true end end
  163. end
  164. --установка элемента
  165. else
  166. if stop ==true then if x == drawx+1 and y==drawy then tpt.create(x-1,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  167. if stop ==true then if x == drawx-1 and y==drawy then tpt.create(x+1,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  168. if stop ==true then if y == drawy+1 and x==drawx then tpt.create(x,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  169. if stop ==true then if y == drawy-1 and x==drawx then tpt.create(x,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  170.  
  171. if stop ==true then if x == drawx+1 and y==drawy+1 then tpt.create(x-1,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  172. if stop ==true then if x == drawx-1 and y==drawy-1 then tpt.create(x+1,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  173. if stop ==true then if y == drawy+1 and x==drawx+1 then tpt.create(x+1,y-1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  174. if stop ==true then if y == drawy+1 and x==drawx-1 then tpt.create(x-1,y+1,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = false end end
  175.  
  176. if stop ==true then if y == drawy and x==drawx then tpt.create(x,y,tpt.element(element)) tpt.delete(i) reset(x,y,i) local stop = true end end
  177. end
  178. if stop == false then stop = true end
  179.  
  180.  
  181.  
  182. if tpt.get_property("type",x-1,y) == 0 or tpt.get_property("type",x-1,y) == type then elseif x>drawx and y<drawy then tpt.set_property("vy",1,i) tpt.set_property("vx",0,i) end
  183. if tpt.get_property("type",x-1,y) == 0 or tpt.get_property("type",x-1,y) == type then elseif x>drawx and y>drawy then tpt.set_property("vy",-1,i) tpt.set_property("vx",0,i) end
  184.  
  185. if tpt.get_property("type",x+1,y) == 0 or tpt.get_property("type",x+1,y) == type then elseif x<drawx and y<drawy then tpt.set_property("vy",1,i) tpt.set_property("vx",0,i) end
  186. if tpt.get_property("type",x+1,y) == 0 or tpt.get_property("type",x+1,y) == type then elseif x<drawx and y>drawy then tpt.set_property("vy",-1,i) tpt.set_property("vx",0,i) end
  187.  
  188. if tpt.get_property("type",x,y-1) == 0 or tpt.get_property("type",x,y-1) == type then elseif y>drawy and x<drawx then tpt.set_property("vx",1,i) tpt.set_property("vy",0,i) end
  189. if tpt.get_property("type",x,y-1) == 0 or tpt.get_property("type",x,y-1) == type then elseif y>drawy and x>drawx then tpt.set_property("vx",-1,i) tpt.set_property("vy",0,i) end
  190.  
  191. if tpt.get_property("type",x,y+1) == 0 or tpt.get_property("type",x,y+1) == type then elseif y<drawy and x<drawx then tpt.set_property("vx",1,i) tpt.set_property("vy",0,i) end
  192. if tpt.get_property("type",x,y+1) == 0 or tpt.get_property("type",x,y+1) == type then elseif y<drawy and x>drawx then tpt.set_property("vx",-1,i) tpt.set_property("vy",0,i) end
  193. end
  194. end
  195.  
  196.  
  197.  
  198.  
  199. function reset(x,y,i)
  200. tpt.unregister_step(drawpixel)
  201. drawy = nil
  202. drawx = nil
  203. stop = false
  204. tpt.set_property("vx",0,i)
  205. tpt.set_property("vy",0,i)
  206. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement