Himitsu_Chan

Untitled

Feb 13th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 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(11,2) -- Set Cursor postion to (2,2)
  23. monitor.write(" Empty ") -- (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 < 9 and mouseHeight == 2 then
  30. -- button one clicked
  31. if CMO == 0 then
  32. shell.run("Iron") -- 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 CMO == 1 then
  38. shell.run("Stop")
  39. monitor.setBackgroundColour((colours.lime)) -- Set Background color lime
  40. monitor.setCursorPos(2,2) -- set cursor pos to rewrite IE
  41. monitor.write(" Iron ") -- rewrite IE
  42. CMO = 0
  43. end
  44. if mouseWidth > 10 and mouseWidth 18 and mouseHeight == 2 then
  45.  
  46. if CES == 0 then
  47. shell.run("Empty")
  48. monitor.setBackgroundColour((colours.red))
  49. monitor.setCursorPos(11,2)
  50. monitor.write(" Empty ")
  51. CES = 1
  52. elseif
  53. shell.run("STOP")
  54. monitor.setBackgroundColour((colours.lime))
  55. monitor.setCursorPos(11,2)
  56. monitor.write(" Empty ")
  57. CES = 0
  58. end
  59. end -- ends the if loop
  60. end -- ends the function
  61.  
  62. repeat
  63.  
  64.  
  65. event,p1,p2,p3 = os.pullEvent() -- Get Event data. event,p1,p2,p3 from os.pullEvent()
  66.  
  67. if event=="monitor_touch" then -- Event Mouse_touch (right click monitor)
  68.  
  69. mouseWidth = p2 -- sets mouseWidth -- Set Mouse Width to p2
  70. mouseHeight = p3 -- and mouseHeight -- Set Mouse Height to p3
  71. checkClickPosition() -- this runs our function -- Runs the pervious CheckClickPosition Function
  72.  
  73. end -- End the IF statement
  74.  
  75. 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