Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local star = {5,5}
- term.redirect(peripheral.wrap("right"))
- local w,h = term.getSize()
- local dir = "++"
- dir = dir:sub(1,1)..dir:sub(2,2)
- function Main()
- redraw(star[1],star[2])
- local posX,posY = term.getCursorPos()
- if posX == 1 then
- dir = "+"..dir:sub(2,2)
- elseif posX == w then
- dir = "-"..dir:sub(2,2)
- end
- if posY == 1 then
- dir = dir:sub(1,1).."+"
- elseif posY == h then
- dir = dir:sub(1,1).."-"
- end
- local modX = dir:sub(1,1)
- local modY = dir:sub(2,2)
- if modX == "+" then
- star[1] = star[1] + 1
- else
- star[1] = star[1] - 1
- end
- if modY == "+" then
- star[2] = star[2] + 1
- else
- star[2] = star[2] - 1
- end
- end
- function redraw(x,y)
- draw("*",x,y)
- sleep(.5)
- draw(" ",x,y)
- end
- function draw(words,x,y)
- term.setCursorPos(x,y)
- write(words)
- end
- while true do
- Main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement