Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stop = true
- function AI(i, x, y, s, n)
- local type = tpt.get_property("type",i)
- -- движение к цели
- if drawx == nil or drawy == nil then
- tpt.set_property("vx",0,i)
- tpt.set_property("vy",0,i)
- else
- if x < drawx and tpt.get_property("vx",i) then
- tpt.set_property("vx",1,i)
- end
- if x > drawx and tpt.get_property("vx",i) then
- tpt.set_property("vx",-1,i)
- end
- if y < drawy and tpt.get_property("vy",i) then
- tpt.set_property("vy",1,i)
- end
- if y > drawy and tpt.get_property("vy",i) then
- tpt.set_property("vy",-1,i)
- end
- if element== "" or element== "delete" or element=="not" then
- -- отправка ботов
- if element=="" then
- if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
- 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
- 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
- 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
- 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
- if stop ==true then if y == drawy and x==drawx then tpt.delete(i) reset(x,y,i) local stop = true end end
- end
- --удаление элемента
- if element=="delete" then
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- end
- --не удалять точку
- if element=="not" then
- if stop ==true then if x == drawx+1 and y==drawy then local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
- if stop ==true then if x == drawx+1 and y==drawy+1 then local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy-1 then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx+1 then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx-1 then local stop = false end end
- if stop ==true then if y == drawy and x==drawx then local stop = true end end
- end
- --установка элемента
- else
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- end
- if stop == false then stop = true end
- end
- end
- function AI2(i, x, y, s, n)
- local type = tpt.get_property("type",i)
- -- движение к цели
- if drawx == nil or drawy == nil then
- tpt.set_property("vx",0,i)
- tpt.set_property("vy",0,i)
- else
- if x < drawx and tpt.get_property("vx",i) then
- tpt.set_property("vx",1,i)
- end
- if x > drawx and tpt.get_property("vx",i) then
- tpt.set_property("vx",-1,i)
- end
- if y < drawy and tpt.get_property("vy",i) then
- tpt.set_property("vy",1,i)
- end
- if y > drawy and tpt.get_property("vy",i) then
- tpt.set_property("vy",-1,i)
- end
- if element== "" or element== "delete" or element=="not" then
- -- отправка ботов
- if element=="" then
- if stop ==true then if x == drawx+1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then tpt.delete(i) reset(x,y,i) local stop = false end end
- 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
- 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
- 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
- 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
- if stop ==true then if y == drawy and x==drawx then tpt.delete(i) reset(x,y,i) local stop = true end end
- end
- --удаление элемента
- if element=="delete" then
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- end
- --не удалять точку
- if element=="not" then
- if stop ==true then if x == drawx+1 and y==drawy then local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx then local stop = false end end
- if stop ==true then if x == drawx+1 and y==drawy+1 then local stop = false end end
- if stop ==true then if x == drawx-1 and y==drawy-1 then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx+1 then local stop = false end end
- if stop ==true then if y == drawy+1 and x==drawx-1 then local stop = false end end
- if stop ==true then if y == drawy and x==drawx then local stop = true end end
- end
- --установка элемента
- else
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- end
- if stop == false then stop = true end
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- end
- end
- function reset(x,y,i)
- tpt.unregister_step(drawpixel)
- drawy = nil
- drawx = nil
- stop = false
- tpt.set_property("vx",0,i)
- tpt.set_property("vy",0,i)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement