Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function move(map)
- os.loadAPI("/game/code/main")
- os.loadAPI("/game/code/maputils")
- --os.loadAPI("/game/code/loadmap")
- map = {}
- if curSteps == nil then
- curSteps = 1
- end
- if plx == nil or
- ply == nil then
- plx, ply = term.getCursorPos()
- end
- if main.detKey(205) then
- if DirFacing == right then
- term.clear()
- oldplx, oldply = plx, ply
- plx = plx+1
- if maputils.checkValue(map, plx, ply) ~= 0 then
- ply, plx = oldply, oldplx
- return false
- end
- term.setCursorPos(plx, ply)
- end
- write(">")
- dirFacing = right
- curSteps = curSteps+1
- term.setCursorPos(plx, ply)
- sleep(0.05)
- elseif main.detKey(203) then
- if dirFacing == left then
- term.clear()
- oldplx, oldply = plx, ply
- plx = plx-1
- if maputils.checkValue(map, ply, plx) ~= 0 then
- plx, ply = oldplx, oldply
- return false
- end
- term.setCursorPos(plx, ply)
- end
- write("<")
- dirFacing = left
- curSteps = curSteps+1
- term.setCursorPos(plx, ply)
- sleep(0.05)
- elseif main.detKey(200) then
- if dirFacing == up then
- term.clear()
- oldplx, oldply = plx, ply
- ply = ply-1
- if maputils.checkValue(map, ply, plx) ~= 0 then
- plx, ply = oldplx, oldply
- return false
- end
- term.setCursorPos(plx, ply)
- end
- write("^")
- dirFacing = up
- curSteps = curSteps+1
- term.setCursorPos(plx, ply)
- sleep(0.05)
- elseif main.detKey(208) then
- if dirFacing == down then
- term.clear()
- oldplx, oldply = plx, ply
- ply = ply+1
- if maputils.checkValue(map, ply, plx) ~= 0 then
- plx, ply = oldplx, oldply
- return false
- end
- term.setCursorPos(plx, ply)
- end
- write("v")
- dirFacing = down
- curSteps = curSteps+1
- term.setCursorPos(plx, ply)
- sleep(0.05)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment