attayi

Jan's Link Book Sorter

Feb 18th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. --Feel free to copy/change for your needs but please give credit where due
  2. --Replace PLACEHOLDER with the name of your peripheral. Within quotes
  3. --Monitor must be on right of computer
  4. --These Options can also be changed by editing "Config" after running this program for the first time
  5. --Changing Config through gui may come at a later date
  6. --Monitor must be 2 wide but can be as high as you like
  7.  
  8. background = colours.black
  9. text = colours.white
  10. bookstand = "PLACEHOLDER" --You can use a bookstand or book receptacle
  11. container = "PLACEHOLDER"
  12.  
  13. ------------------------Only change above this line
  14. function Config(c1,c2)
  15. Config = {}
  16. Config["COLOUR"] = c1
  17. Config["TEXT"] = c2
  18. Config["STANDorRECIPTACLE"] = bookstand
  19. Config["CONTAINER"] = container
  20. local config_file = fs.open("Config", "w")
  21. config_file.write(textutils.serialize(Config))
  22. config_file.close()
  23. end
  24.  
  25. if fs.exists("Config") then
  26.     print("CONFIG FOUND")
  27. else Config(background,text)
  28. end
  29.  
  30. if fs.exists("Portal_API") then
  31.     print("API FOUND")
  32. else shell.run("pastebin", "get", "JmdqiXBZ", "Portal_API")
  33. end
  34.  
  35. os.loadAPI("Portal_API")
  36.  
  37. if fs.exists("Active List") then
  38.     print("ACTIVE LIST FOUND")
  39. else  local file = fs.open("Active List", "w")
  40.         file.write("display1")
  41.         file.close()
  42. end
  43.  
  44. fs.delete("Buttons")
  45. fs.delete("Buttons2")
  46. List_num = Portal_API.Get_Active_List()
  47. Portal_API.Start_screen()
  48.  
  49. if List_num == "display1" then
  50.     Portal_API.list1()
  51. elseif List_num == "display2" then
  52.     Portal_API.list2()
  53. end
  54.  
  55. term.clear()
  56. term.setCursorPos(1,1)
  57. print("Program is written by Jandras aka Janadin")
  58. print("Edit Config with peripheral names on first use")
  59. print("Linkbook Capacity is: "..Portal_API.cap)
  60.  
  61. while List_num == "display1" do
  62.     Portal_API.New()
  63.     if fs.exists("Buttons") then
  64.         shell.run("Buttons")
  65.     end
  66.     Portal_API.List1set()
  67.     Portal_API.List2set()
  68.     Portal_API.Get_Active_List()
  69. end
  70.  
  71. while List_num == "display2" do
  72.     Portal_API.New()
  73.     if fs.exists("Buttons2") then
  74.         shell.run("Buttons2")
  75.     end
  76.     Portal_API.List1set()
  77.     Portal_API.List2set()
  78.     Portal_API.Get_Active_List()
  79. end
Advertisement
Add Comment
Please, Sign In to add comment