Himitsu_Chan

Untitled

Feb 13th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. CMO = 0 -- Counter Counter Metal Input
  2.  
  3.  
  4. mouseWidth = 0 -- Create MouseWidth Variable
  5. mouseHeight = 0 -- Create MouseHeight Variable
  6. monitor = peripheral.wrap("monitor_0") -- Wrap monitor_0 monitor to "monitor"
  7.  
  8. monitor.setBackgroundColour((colors.black)) -- Return to standart color BEFORE clearing the screen
  9. monitor.clear() -- Clear Monitor
  10. monitor.setCursorPos(1,1) -- Set Cursor to Pos 1,1
  11.  
  12. w,h=monitor.getSize() -- set W to Width of Monitor and H to Height
  13.  
  14. print(w) -- Print Width
  15. print(h) -- Print Height
  16.  
  17. monitor.setBackgroundColour((colours.lime)) -- Set monitor Background Color For button creation
  18.  
  19. monitor.setCursorPos(2,2)
  20. monitor.write(" Iron ")
  21.  
  22. monitor.setCursorPos(8,2) -- Set Cursor postion to (2,2)
  23. monitor.write(" Manyullyn ") -- (Write what ever needs to be 9 characters.)
  24.  
  25. monitor.setBackgroundColour((colours.black)) -- Set Background color to black
  26.  
  27.  
  28. function checkClickPosition()
  29. if mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 2 then
  30. -- button one clicked
  31. if CMO == 0 then
  32. shell.run("IE") -- Run program IE
  33. monitor.setBackgroundColour((colours.red)) -- Set Background color red
  34. monitor.setCursorPos(2,2) -- set cursor pos to rewrite IE
  35. monitor.write(" Iron ") -- rewrite IE
  36. CMO = 1
  37. elseif CIE == 1 then
  38. shell.run("SIE")
  39. monitor.setBackgroundColour((colours.lime)) -- Set Background color lime
  40. monitor.setCursorPos(2,2) -- set cursor pos to rewrite IE
  41. monitor.write(" OFF ") -- rewrite IE
  42. CMO = 0
  43. end
  44.  
  45.  
  46. end -- ends the if loop
  47. end -- ends the function
  48.  
  49. repeat
  50.  
  51.  
  52. event,p1,p2,p3 = os.pullEvent() -- Get Event data. event,p1,p2,p3 from os.pullEvent()
  53.  
  54. if event=="monitor_touch" then -- Event Mouse_touch (right click monitor)
  55.  
  56. mouseWidth = p2 -- sets mouseWidth -- Set Mouse Width to p2
  57. mouseHeight = p3 -- and mouseHeight -- Set Mouse Height to p3
  58. checkClickPosition() -- this runs our function -- Runs the pervious CheckClickPosition Function
  59.  
  60. end -- End the IF statement
  61.  
  62. until event=="char" and p1==("x") -- Until the event "char" position 1 is X (aka when X is pressed) the programm will loop
Advertisement
Add Comment
Please, Sign In to add comment