Advertisement
Guest User

Untitled

a guest
Jul 16th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. --[[ VARIABLES ]]--
  2.  
  3. local mon = peripheral.wrap("top")
  4. local CowBool = false
  5.  
  6. --[[ FUNCTIONS ]]--
  7.  
  8. function MainButtons()
  9.     button.setTable("Farm Menu", FarmMenu, 10, 20, 3, 5)
  10.     button.setTable("Test2", main2, 22, 32, 3, 5)
  11.     button.setTable("Test3", main3, 10, 20, 8, 10)
  12.     button.setTable("Test4", main4, 22, 32, 8, 10)
  13.     button.screen()
  14. end
  15.  
  16. function getClick()
  17.     event, side, x, y = os.pullEvent("monitor_touch")
  18.     button.checkxy(x,y)
  19. end
  20.  
  21. function UpdateCowBool() --Currently unused, will remove later
  22.     local filer = fs.open("buttonstates", "r")
  23.     local ReadCow = filer.readLine()
  24.     --CowBool = ReadCow()
  25. end
  26.  
  27. function CheckCowBool() --Checks the file "buttonstates" for the boolean of the CowFarm, and tries to set CowBool to the current, correct state, defined in the file "buttonstates",
  28.     local filer = fs.open("buttonstates", "r")
  29.     local ReadCow = filer.readLine()
  30.     CowBool = ReadCow()
  31.    
  32.     if ReadCow == "true" then
  33.         button.toggleButton("Cow Farm")
  34.     end
  35.    
  36.     filer.close()
  37.    
  38.     local filew = fs.open("buttonstates", "w")
  39.     filew.writeLine(CowBool)
  40.     filew.close()
  41. end
  42.  
  43. function FarmButtons()
  44.     button.setTable("Cow Farm", CowFarm, 10, 20, 3, 5)
  45.     button.setTable("Blaze Farm", BlazeFarm, 22, 32, 3, 5)
  46.     button.setTable("Back", back, 10, 17, 15, 17)
  47.     button.screen()
  48. end
  49.  
  50. function FarmMenu() --Clears the past(main) menu and runs/displays the "Farms" menu
  51.     button.flash("Farm Menu")
  52.     sleep(.1)
  53.     button.clearTable()
  54.     FarmButtons()
  55.     button.heading("Farms")
  56.    
  57.     CheckCowBool()
  58. end
  59.  
  60. function main2()
  61.     --Do Stuff
  62. end
  63.  
  64. function main3()
  65.     --Do Stuff
  66. end
  67.  
  68. function main4()
  69.     --Do stuff
  70. end
  71.  
  72. function back()
  73.     button.flash("Back")
  74.     button.clearTable()
  75.     MainButtons()
  76.     button.heading("N1ght Network")
  77. end
  78.  
  79. function CowFarm()
  80.     CowBool = not CowBool
  81.     local filew = fs.open("buttonstates", "w")
  82.    
  83.     filew.writeLine(CowBool)
  84.     filew.close()
  85.    
  86.     button.toggleButton("Cow Farm")
  87.     rs.setBundledOutput("bottom", colors.white)
  88. end
  89.  
  90. function BlazeFarm()
  91.     --Toggle the BlazeFarm
  92. end
  93.  
  94. function CheckWireStates()
  95.     local filer = fs.open("buttonstates", "r")
  96.     local ReadBool = filer.readLine()
  97. end
  98.  
  99. --[[ MAIN ]]--
  100.  
  101. os.loadAPI("button")
  102. mon.clear()
  103. MainButtons()
  104. button.heading("N1ght Network")
  105. CheckCowBool()
  106. while true do
  107.     getClick()
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement