Advertisement
kurruk

Smeltery Auto Program

Jun 30th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. --First time running
  2.   if not fs.exists("kapi") then
  3.     shell.run("pastebin","get","mK2SZvHs","kapi")
  4.     print("enjoy")
  5.   end
  6. --End first startup
  7.  
  8. --Setting Variables
  9. os.loadAPI("kapi") --Loads my api
  10. local monitor = peripheral.find("monitor")
  11. local control = peripheral.find("crafters_smeltery")
  12.  
  13. --Getting info from smeltery controller and returning as a value
  14. function getInfo()
  15.   local q = control.getInfo() --returns a table
  16.   return q
  17. end
  18.  
  19. --Checking if there is any fluid in smeltery returns true or false
  20. function hasFluid()
  21.   local fluid = getInfo()
  22.   if fluid["contents"] then
  23.     return true
  24.   else
  25.     return false
  26.   end
  27. end
  28.  
  29. --Returns name of the fluid in the smeltery
  30. function fluidName()
  31.   local fluid = getInfo()
  32.   return fluid["contents"]["rawName"]
  33. end
  34.  
  35. --Returns the amount of the fluid in the smeltery
  36. function fluidAmount()
  37.   local fluid = getInfo()
  38.   return fluid["contents"]["amount"]
  39. end
  40.  
  41. --Clears monitor
  42. function monitorReset()
  43.   monitor.clear()
  44.   monitor.setCursorPos(1,1)
  45. end
  46.  
  47. --Unknown as of now
  48. function monitorOutput()
  49.   if hasFluid() then
  50.     monitorReset()
  51.     monitor.write("Contains: "..fluidName())
  52.     monitor.setCursorPos(1,2)
  53.     monitor.write("Amount: "..kapi.commaValue(fluidAmount()).." MB") --Runs a function to add a comma at the right spot
  54.   else
  55.     print("No fluid in smeltery")
  56.   end
  57. end
  58.  
  59. function checkAmount()
  60.   local fluid = fluidAmount()
  61. end
  62.  
  63. monitorOutput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement