Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if posx == nil then posx = 1 end
- if posy == nil then posy = 0 end
- if fieldx == nil then fieldx = 9 end
- if fieldy == nil then fieldy = 9 end
- if wait == nil then wait = 540 end
- if waitafter == nil then waitafter = true
- function mine()
- print("doing stuff here")
- end
- function move(dx, dy)
- moveDirX(posx, dx)
- moveDirY(posy, dy)
- end
- function moveDirX(ax, dx)
- delta = ax-dx
- if delta < 0 then step(delta, 0)
- elseif delta > 0 then step(delta, 0)
- else print("Nothing to do in X-Direction")
- end
- function moveDirY(ay, dy)
- delta = ay-dy
- if delta < 0 then step(delta, 1)
- elseif delta > 0 then step(delta, 1)
- else print("Nothing to do in Y-Direction")
- end
- function betrag(zahl1)
- if zahl1 < 0 then return zahl1 * -1
- else return zahl1
- end
- end
- function step(count, axis)
- if axis == 0 then
- for i=1, betrag(count) do
- if count > 0 then
- moveRight()
- return true
- elseif count < 0 then
- moveLeft()
- return true
- end
- end
- elseif axis == 1 then
- for i=1, betrag(count) do
- if count > 0 then
- moveForward()
- return true
- elseif count < 0 then
- moveBack()
- return true
- end
- end
- end
- end
- function moveRight()
- print("Moving to the right. New coordinates should be: "..posx+1.." / "..posy)
- end
- function moveLeft()
- print("Moving to the right. New coordinates should be: "..posx-1.." / "..posy)
- end
- function moveForward()
- print("Moving to the right. New coordinates should be: "..posx.." / "..posy+1)
- end
- function moveBack()
- print("Moving to the right. New coordinates should be: "..posx.." / "..posy-1)
- end
- if not waitafter then sleep(wait)
- --.....
- move(1,1)
- if waitafter then sleep(wait)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement