Advertisement
Himitsu_Chan

Untitled

Feb 13th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. CMO = 0 -- Counter Metal Input
  2. CES = 0 -- Counter Empty Smeltery
  3.  
  4. mouseWidth = 0 -- Create MouseWidth Variable
  5. mouseHeight = 0 -- Create MouseHeight Variable
  6. monitor = peripheral.wrap("monitor_1") -- 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(2,4)
  23. monitor.write(" Invar ")
  24.  
  25. monitor.setCursorPos(11,2) -- Set Cursor postion to (2,2)
  26. monitor.write(" Empty ") -- (Write what ever needs to be 9 characters.)
  27.  
  28. monitor.setBackgroundColour((colours.black)) -- Set Background color to black
  29.  
  30.  
  31. function checkClickPosition()
  32. if mouseWidth > 1 and mouseWidth < 9 and mouseHeight == 2 then
  33. -- button one clicked
  34. if CMO == 0 then
  35. shell.run("Iron") -- Run program IE
  36. monitor.setBackgroundColour((colours.red)) -- Set Background color red
  37. monitor.setCursorPos(2,2) -- set cursor pos to rewrite IE
  38. monitor.write(" Iron ") -- rewrite IE
  39. CMO = 1
  40. elseif CMO == 1 then
  41. shell.run("Stop")
  42. monitor.setBackgroundColour((colours.lime)) -- Set Background color lime
  43. monitor.setCursorPos(2,2) -- set cursor pos to rewrite IE
  44. monitor.write(" Iron ") -- rewrite IE
  45. CMO = 0
  46. end
  47. elseif mouseWidth > 1 and mouseWidth < 9 and mouseHeight == 4 then
  48.  
  49. if CMO == 0 then
  50. shell.run("Invar") -- Run program IE
  51. monitor.setBackgroundColour((colours.red)) -- Set Background color red
  52. monitor.setCursorPos(2,4) -- set cursor pos to rewrite IE
  53. monitor.write(" Invar ") -- rewrite IE
  54. CMO = 1
  55. elseif CMO == 1 then
  56. shell.run("Stop")
  57. monitor.setBackgroundColour((colours.lime)) -- Set Background color lime
  58. monitor.setCursorPos(2,4) -- set cursor pos to rewrite IE
  59. monitor.write(" Invar ") -- rewrite IE
  60. CMO = 0
  61. end
  62.  
  63.  
  64. elseif mouseWidth > 10 and mouseWidth < 18 and mouseHeight == 2 then
  65.  
  66. if CES == 0 then
  67. shell.run("Empty")
  68. monitor.setBackgroundColour((colours.red))
  69. monitor.setCursorPos(11,2)
  70. monitor.write(" Empty ")
  71. CES = 1
  72. elseif CES == 1 then
  73. shell.run("Stop")
  74. monitor.setBackgroundColour((colours.lime))
  75. monitor.setCursorPos(11,2)
  76. monitor.write(" Empty ")
  77. CES = 0
  78. end
  79. end -- ends the if loop
  80. end -- ends the function
  81.  
  82. repeat
  83.  
  84.  
  85. event,p1,p2,p3 = os.pullEvent() -- Get Event data. event,p1,p2,p3 from os.pullEvent()
  86.  
  87. if event=="monitor_touch" then -- Event Mouse_touch (right click monitor)
  88.  
  89. mouseWidth = p2 -- sets mouseWidth -- Set Mouse Width to p2
  90. mouseHeight = p3 -- and mouseHeight -- Set Mouse Height to p3
  91. checkClickPosition() -- this runs our function -- Runs the pervious CheckClickPosition Function
  92.  
  93. end -- End the IF statement
  94.  
  95. 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
Advertisement