Mr_Rockers

CustomSmeltingScript

Aug 5th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local smelt = false
  2. local runProg = true
  3.  
  4. local lastOutput = false
  5.  
  6. function cls()
  7.     term.clear()
  8.     term.setCursorPos(1,1)
  9. end
  10.  
  11. function writeX (monitor, x, y)
  12.     monitor.setCursorPos(x,y)
  13.     monitor.write("x")
  14. end
  15.  
  16. while runProg do
  17.  
  18.     if peripheral.isPresent("left") then
  19.         local leftMonitor = peripheral.wrap("left")
  20.         leftMonitor.clear()
  21.         leftMonitor.setCursorPos(1,1)
  22.         leftMonitor.write("Smelt:")
  23.         leftMonitor.setCursorPos(1,2)
  24.         leftMonitor.write((smelt and "YES" or "NO"))
  25.        
  26.         if (not smelt) then
  27.             writeX(leftMonitor,3,3)
  28.             writeX(leftMonitor,5,3)
  29.             writeX(leftMonitor,4,4)
  30.             writeX(leftMonitor,3,5)
  31.             writeX(leftMonitor,5,5)
  32.         else
  33.             writeX(leftMonitor,2,4)
  34.             writeX(leftMonitor,3,5)
  35.             writeX(leftMonitor,4,5)
  36.             writeX(leftMonitor,5,4)
  37.             writeX(leftMonitor,6,3)
  38.         end
  39.     end
  40.  
  41.     cls()
  42.     print("Smelting: " .. (smelt and "ENABLED" or "DISABLED"))
  43.     print("")
  44.     print("Type \"help\" for more options...")
  45.     local input = read()
  46.     cls()
  47.    
  48.     if input == "help" then
  49.  
  50.         print ("\"enable\" - enables smelting.")
  51.         print ("\"disable\" - disables smelting.")
  52.         print ("\"help\" - prints this page.")
  53.         print ("\"exit\" - exits to terminal.")
  54.         print ("")
  55.         print ("Press any key to continue...")
  56.         os.pullEvent ('key')
  57.  
  58.     elseif input == "exit" then
  59.        
  60.         runProg = false
  61.         print ("Goodbye!")
  62.         os.sleep(3)
  63.         cls()
  64.        
  65.     elseif input == "enable" then
  66.  
  67.         if smelt ~= true then
  68.             print("Enabling...")
  69.             smelt = true
  70.             redstone.setOutput("back", not lastOutput)
  71.             os.sleep (0.1)
  72.             redstone.setOutput("back", lastOutput)
  73.             os.sleep (0.1)
  74.             lastOutput = lastOutput --Just in here for documentation purposes
  75.         else
  76.             print ("Smelting is already enabled!")
  77.             os.sleep(3)
  78.         end
  79.    
  80.     elseif input == "disable" then
  81.  
  82.         if smelt ~= false then
  83.             print("Disabling...")
  84.             smelt = false
  85.             redstone.setOutput("back", not lastOutput)
  86.             os.sleep (0.1)
  87.             lastOutput = not lastOutput
  88.         else
  89.             print("Smelting is already disabled!")
  90.             os.sleep(3)
  91.         end
  92.  
  93.     else
  94.  
  95.         print("Invalid command \"" .. input .. "\"")
  96.         os.sleep(3)
  97.  
  98.     end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment