Hiranus

window move

Oct 2nd, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local screen = window.create(term.current(),1,1,100,100)
  2. screen.setCursorPos(15,15)
  3. screen.write("haha")
  4. local pp2=0
  5. local pp3=0
  6. local motionX=0
  7. local motionY=0
  8. local event,p1,p2,p3,p4,p5
  9. while true do
  10.     local posX,posY = screen.getPosition()
  11.      event,p1,p2,p3,p4,p5 = os.pullEvent()
  12.     if event=="mouse_click" and p1==2 then
  13.         pp2=p2
  14.         pp3=p3
  15.     elseif event=="mouse_drag" and p1==2 then
  16.         if pp2<p2 then
  17.             motionX=1
  18.             pp2=p2
  19.         elseif pp2>p2 then
  20.             motionX=-1
  21.             pp2=p2
  22.         else
  23.             motionX=0
  24.             pp2=p2
  25.         end
  26.        
  27.         if pp3<p3 then
  28.             motionY=1
  29.             pp3=p3
  30.         elseif pp3>p3 then
  31.             motionY=-1
  32.             pp3=p3
  33.         else
  34.             motionY=0
  35.             pp3=p3
  36.         end
  37.         screen.reposition(posX+motionX,posY+motionY)
  38.     elseif event=="mouse_click" and p1==3 then
  39.         screen.reposition(1,1)
  40.     end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment