Guest User

startup

a guest
Oct 16th, 2013
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. -- ############################################################
  2. function drag()
  3.  while true do
  4.    event, button, X, Y = os.pullEvent("mouse_drag") -- ### mouse drag function
  5.    XY = X..","..Y
  6. -- ############################################################
  7.  
  8.     if button == 1 then -- window design
  9.    
  10.       term.setBackgroundColor(8)
  11.       shell.run("clear")
  12.       term.setBackgroundColor(8)
  13.       term.setCursorPos(X-8,Y)
  14.       term.setBackgroundColor(2048)
  15.       write("Test            ")
  16.       term.setBackgroundColor(1)
  17.       term.setBackgroundColor(16384)
  18.       write("X") -- close (does not work) ####
  19.       term.setBackgroundColor(256)
  20.       term.setCursorPos(X-8,Y+1)
  21.       print("                 ")
  22.       term.setCursorPos(X-8,Y+2)
  23.       print("     Hello       ")
  24.       term.setCursorPos(X-8,Y+3)
  25.       print("                 ")
  26.       term.setCursorPos(X-8,Y+4)
  27.       print("                %")
  28.      
  29.     end
  30.   end
  31.  end
  32. -- ############################################################
  33. function click()
  34. while true do
  35.      event, button, X, Y = os.pullEvent("mouse_drag") -- ### mouse drag function
  36.      XY = X..","..Y
  37.      event, button, X2, Y2 = os.pullEvent("mouse_click") -- click (close) function
  38.      XY2 = X2..","..Y2
  39.      
  40.      if XY2 == (X + 8) .. "," .. Y and button == 1 then -- #### Close position
  41.      
  42.      shell.run("clear")
  43.      print("Restart..")
  44.      sleep(1)
  45.      end
  46.      
  47. end
  48. end
  49. -- ###########################Start#################################
  50. term.setBackgroundColor(8)
  51. shell.run("clear")
  52. print("Drag the mouse..\n# ----drag---> #")
  53. parallel.waitForAny(drag, click)
Add Comment
Please, Sign In to add comment