Advertisement
jonnathonchristopher

Setup

Mar 2nd, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.27 KB | None | 0 0
  1. --[[
  2.  
  3. Rail Cart elevator monitor By Jonnathon Clayton (AKA THC Butterz) V2.0.0
  4. Note: For a great comptercraft controlled elevator check out Ominous Penguin's tutorial here:  
  5. https://www.youtube.com/watch?v=OiMmMBS5e_s#t=756
  6.  
  7. Special Thanks and Credit:
  8. Credit to ben657 for his config file API
  9. Special thanks to Ominous Penguin for tips and coding advice.
  10.  
  11. -- Maximum of 16 floors, floors must have unique color wire
  12. -- Floors must be wired in color order per Color API
  13. -- Refer to the Color API here:  http://computercraft.info/wiki/Colors_%28API%29
  14. -- floor 1 = white, floor 2 = orange, floor 16 = black etc...
  15.  
  16. --]]
  17.  
  18. fs.delete("req/config")
  19. shell.run("pastebin", "get", "rfqYgmrL", "req/config")
  20. print("Downloading Required Files")
  21. sleep(2)
  22.  
  23. os.loadAPI("req/config")
  24.  
  25. config.load("configs","server")
  26. term.clear()
  27. config.writeVal("floors","nil")
  28. config.save()
  29.  
  30. config.load("configs","server")
  31. term.clear()
  32. config.writeVal("bcol","nil")
  33. config.save()
  34.  
  35. config.load("configs","server")
  36. term.clear()
  37. config.writeVal("tcol","nil")
  38. config.save()
  39.  
  40. config.load("configs","server")
  41. term.clear()
  42. config.writeVal("scal","nil")
  43. config.save()
  44.  
  45. config.load("configs","server")
  46. term.clear()
  47. config.writeVal("f1","nil")
  48. config.save()
  49.  
  50. config.load("configs","server")
  51. term.clear()
  52. config.writeVal("f2","nil")
  53. config.save()
  54.  
  55. config.load("configs","server")
  56. term.clear()
  57. config.writeVal("f3","nil")
  58. config.save()
  59.  
  60. config.load("configs","server")
  61. term.clear()
  62. config.writeVal("f4","nil")
  63. config.save()
  64.  
  65. config.load("configs","server")
  66. term.clear()
  67. config.writeVal("f5","nil")
  68. config.save()
  69.  
  70. config.load("configs","server")
  71. term.clear()
  72. config.writeVal("f6","nil")
  73. config.save()
  74.  
  75. config.load("configs","server")
  76. term.clear()
  77. config.writeVal("f7","nil")
  78. config.save()
  79.  
  80. config.load("configs","server")
  81. term.clear()
  82. config.writeVal("f8","nil")
  83. config.save()
  84.  
  85. config.load("configs","server")
  86. term.clear()
  87. config.writeVal("f9","nil")
  88. config.save()
  89.  
  90. config.load("configs","server")
  91. term.clear()
  92. config.writeVal("f10","nil")
  93. config.save()
  94.  
  95. config.load("configs","server")
  96. term.clear()
  97. config.writeVal("f11","nil")
  98. config.save()
  99.  
  100. config.load("configs","server")
  101. term.clear()
  102. config.writeVal("f12","nil")
  103. config.save()
  104.  
  105. config.load("configs","server")
  106. term.clear()
  107. config.writeVal("f13","nil")
  108. config.save()
  109.  
  110. config.load("configs","server")
  111. term.clear()
  112. config.writeVal("f14","nil")
  113. config.save()
  114.  
  115. config.load("configs","server")
  116. term.clear()
  117. config.writeVal("f15","nil")
  118. config.save()
  119.  
  120. config.load("configs","server")
  121. term.clear()
  122. config.writeVal("f16","nil")
  123. config.save()
  124.  
  125. config.load("configs","server")
  126. term.clear()
  127. config.writeVal("m1","nil")
  128. config.save()
  129.  
  130. config.load("configs","server")
  131. term.clear()
  132. config.writeVal("m2","nil")
  133. config.save()
  134.  
  135. config.load("configs","server")
  136. term.clear()
  137. config.writeVal("m3","nil")
  138. config.save()
  139.  
  140. config.load("configs","server")
  141. term.clear()
  142. config.writeVal("m4","nil")
  143. config.save()
  144.  
  145. config.load("configs","server")
  146. term.clear()
  147. config.writeVal("m5","nil")
  148. config.save()
  149.  
  150. config.load("configs","server")
  151. term.clear()
  152. config.writeVal("m6","nil")
  153. config.save()
  154.  
  155. config.load("configs","server")
  156. term.clear()
  157. config.writeVal("m7","nil")
  158. config.save()
  159.  
  160. config.load("configs","server")
  161. term.clear()
  162. config.writeVal("m8","nil")
  163. config.save()
  164.  
  165. config.load("configs","server")
  166. term.clear()
  167. config.writeVal("m9","nil")
  168. config.save()
  169.  
  170. config.load("configs","server")
  171. term.clear()
  172. config.writeVal("m10","nil")
  173. config.save()
  174.  
  175. config.load("configs","server")
  176. term.clear()
  177. config.writeVal("m11","nil")
  178. config.save()
  179.  
  180. config.load("configs","server")
  181. term.clear()
  182. config.writeVal("m12","nil")
  183. config.save()
  184.  
  185. config.load("configs","server")
  186. term.clear()
  187. config.writeVal("m13","nil")
  188. config.save()
  189.  
  190. config.load("configs","server")
  191. term.clear()
  192. config.writeVal("m14","nil")
  193. config.save()
  194.  
  195. config.load("configs","server")
  196. term.clear()
  197. config.writeVal("m15","nil")
  198. config.save()
  199.  
  200. config.load("configs","server")
  201. term.clear()
  202. config.writeVal("m16","nil")
  203. config.save()
  204.  
  205. config.load("configs","server")
  206.  
  207. term.clear()
  208. term.setCursorPos(1, 1)
  209. print("What color do you want the monitor backgrounds to be?")
  210. tbcol = string.lower(io.read())
  211. if tbcol == "white" then
  212. bcol = 1
  213.  
  214. else if tbcol == "orange" then
  215. bcol = 2
  216.  
  217. else if tbcol == "magenta" then
  218. bcol = 4
  219.  
  220. else if tbcol == "lightblue" then
  221. bcol = 8
  222.  
  223. else if tbcol == "yellow" then
  224. bcol = 16
  225.  
  226. else if tbcol == "lime" then
  227. bcol = 32
  228.  
  229. else if tbcol == "pink" then
  230. bcol = 64
  231.  
  232. else if tbcol == "grey" then
  233. bcol = 128
  234.  
  235. else if tbcol == "lightgrey" then
  236. bcol = 256
  237.  
  238. else if tbcol == "cyan" then
  239. bcol = 512
  240.  
  241. else if tbcol == "purple" then
  242. bcol = 1024
  243.  
  244. else if tbcol == "blue" then
  245. bcol = 2048
  246.  
  247. else if tbcol == "brown" then
  248. bcol = 4096
  249.  
  250. else if tbcol == "green" then
  251. bcol = 8192
  252.  
  253. else if tbcol == "red" then
  254. bcol = 16384
  255.  
  256. else if tbcol == "black" then
  257. bcol = 32768
  258. end
  259. end
  260. end
  261. end
  262. end
  263. end
  264. end
  265. end
  266. end
  267. end
  268. end
  269. end
  270. end
  271. end
  272. end
  273. end
  274. config.writeVal("bcol",bcol)
  275. config.save()
  276.  
  277. config.load("configs","server")
  278. term.clear()
  279. term.setCursorPos(1, 1)
  280. print("What color do you want the monitor text to be?")
  281. ttcol = string.lower(io.read())
  282. if ttcol == "white" then
  283. tcol = 1
  284.  
  285. else if ttcol == "orange" then
  286. tcol = 2
  287.  
  288. else if ttcol == "magenta" then
  289. tcol = 4
  290.  
  291. else if ttcol == "lightblue" then
  292. tcol = 8
  293.  
  294. else if ttcol == "yellow" then
  295. tcol = 16
  296.  
  297. else if ttcol == "lime" then
  298. tcol = 32
  299.  
  300. else if ttcol == "pink" then
  301. tcol = 64
  302.  
  303. else if ttcol == "grey" then
  304. tcol = 128
  305.  
  306. else if ttcol == "lightgrey" then
  307. tcol = 256
  308.  
  309. else if ttcol == "cyan" then
  310. tcol = 512
  311.  
  312. else if ttcol == "purple" then
  313. tcol = 1024
  314.  
  315. else if ttcol == "blue" then
  316. tcol = 2048
  317.  
  318. else if ttcol == "brown" then
  319. tcol = 4096
  320.  
  321. else if ttcol == "green" then
  322. tcol = 8192
  323.  
  324. else if ttcol == "red" then
  325. tcol = 16384
  326.  
  327. else if ttcol == "black" then
  328. tcol = 32768
  329. end
  330. end
  331. end
  332. end
  333. end
  334. end
  335. end
  336. end
  337. end
  338. end
  339. end
  340. end
  341. end
  342. end
  343. end
  344. end
  345. config.writeVal("tcol",tcol)
  346. config.save()
  347.  
  348. config.load("configs","server")
  349. term.clear()
  350. term.setCursorPos(1, 1)
  351. print("On a scale from 1 to 5")
  352. term.setCursorPos(1, 2)
  353. print("1 being tiny and 5 being massive")
  354. term.setCursorPos(1, 3)
  355. print("How big do you want the monitor text?")
  356. scal = tonumber(read())
  357. config.writeVal("scal",scal)
  358. config.save()
  359.  
  360. config.load("configs","server")
  361. term.clear()
  362. term.setCursorPos(1, 1)
  363. print("How many floors do you have?")
  364. number = tonumber(read())
  365. config.writeVal("floors",number)
  366. config.save()
  367.  
  368. config.load("configs","server")
  369. term.clear()
  370. term.setCursorPos(1, 1)
  371. nof = tonumber(config.readVal("floors"))
  372. if nof >= 2 then
  373. if nof <= 16 then
  374.     term.clear()
  375.     term.setCursorPos(1, 1)
  376.     print("What is the name of your first floor?")
  377.     f1 = read()
  378.     config.writeVal("f1",f1)
  379.     print("What is the number of your first floor monitor?")
  380.     m1 = read()
  381.     config.writeVal("m1",m1)
  382.     config.save()
  383.    
  384.     term.clear()
  385.     term.setCursorPos(1, 1)
  386.     config.load("configs","server")
  387.     print("What is the name of your second floor?")
  388.     f2 = read()
  389.     config.writeVal("f2",f2)
  390.     print("What is the number of your second floor monitor?")
  391.     m2 = read()
  392.     config.writeVal("m2",m2)
  393.     config.save()
  394.  
  395.     if nof >= 3 then
  396.         term.clear()
  397.         term.setCursorPos(1, 1)
  398.         config.load("configs","server")
  399.         print("What is the name of your third floor?")
  400.         f3 = read()
  401.         config.writeVal("f3",f3)
  402.         print("What is the number of your third floor monitor?")
  403.         m3 = read()
  404.         config.writeVal("m3",m3)
  405.         config.save()
  406.     end
  407.    
  408.     if nof >= 4 then
  409.         term.clear()
  410.         term.setCursorPos(1, 1)
  411.         config.load("configs","server")
  412.         print("What is the name of your forth floor?")
  413.         f4 = read()
  414.         config.writeVal("f4",f4)
  415.         print("What is the number of your forth floor monitor?")
  416.         m4 = read()
  417.         config.writeVal("m4",m4)
  418.         config.save()
  419.     end
  420.    
  421.     if nof >= 5 then
  422.         term.clear()
  423.         term.setCursorPos(1, 1)
  424.         config.load("configs","server")
  425.         print("What is the name of your fifth floor?")
  426.         f5 = read()
  427.         config.writeVal("f5",f5)
  428.         print("What is the number of your fifth floor monitor?")
  429.         m5 = read()
  430.         config.writeVal("m5",m5)
  431.         config.save()
  432.     end
  433.    
  434.     if nof >= 6 then
  435.         term.clear()
  436.         term.setCursorPos(1, 1)
  437.         config.load("configs","server")
  438.         print("What is the name of your sixth floor?")
  439.         f6 = read()
  440.         config.writeVal("f6",f6)
  441.         print("What is the number of your sixth floor monitor?")
  442.         m6 = read()
  443.         config.writeVal("m6",m6)
  444.         config.save()
  445.     end
  446.    
  447.     if nof >= 7 then
  448.         term.clear()
  449.         term.setCursorPos(1, 1)
  450.         config.load("configs","server")
  451.         print("What is the name of your seventh floor?")
  452.         f7 = read()
  453.         config.writeVal("f7",f7)
  454.         print("What is the number of your seventh floor monitor?")
  455.         m7 = read()
  456.         config.writeVal("m7",m7)
  457.         config.save()
  458.     end
  459.    
  460.     if nof >= 8 then
  461.         term.clear()
  462.         term.setCursorPos(1, 1)
  463.         config.load("configs","server")
  464.         print("What is the name of your eighth floor?")
  465.         f8 = read()
  466.         config.writeVal("f8",f8)
  467.         print("What is the number of your eighth floor monitor?")
  468.         m8 = read()
  469.         config.writeVal("m8",m8)
  470.         config.save()
  471.     end
  472.    
  473.     if nof >= 9 then
  474.         term.clear()
  475.         term.setCursorPos(1, 1)
  476.         config.load("configs","server")
  477.         print("What is the name of your ninth floor?")
  478.         f9 = read()
  479.         config.writeVal("f9",f9)
  480.         print("What is the number of your ninth floor monitor?")
  481.         m9 = read()
  482.         config.writeVal("m9",m9)
  483.         config.save()
  484.     end
  485.    
  486.     if nof >= 10 then
  487.         term.clear()
  488.         term.setCursorPos(1, 1)
  489.         config.load("configs","server")
  490.         print("What is the name of your tenth floor?")
  491.         f10 = read()
  492.         config.writeVal("f10",f10)
  493.         print("What is the number of your tenth floor monitor?")
  494.         m10 = read()
  495.         config.writeVal("m10",m10)
  496.         config.save()
  497.     end
  498.    
  499.     if nof >= 11 then
  500.         term.clear()
  501.         term.setCursorPos(1, 1)
  502.         config.load("configs","server")
  503.         print("What is the name of your eleventh floor?")
  504.         f11 = read()
  505.         config.writeVal("f11",f11)
  506.         print("What is the number of your eleventh floor monitor?")
  507.         m11 = read()
  508.         config.writeVal("m11",m11)
  509.         config.save()
  510.     end
  511.    
  512.     if nof >= 12 then
  513.         term.clear()
  514.         term.setCursorPos(1, 1)
  515.         config.load("configs","server")
  516.         print("What is the name of your twelfth floor?")
  517.         f12 = read()
  518.         config.writeVal("f12",f12)
  519.         print("What is the number of your twelfth floor monitor?")
  520.         m12 = read()
  521.         config.writeVal("m12",m12)
  522.         config.save()
  523.     end
  524.    
  525.     if nof >= 13 then
  526.         term.clear()
  527.         term.setCursorPos(1, 1)
  528.         config.load("configs","server")
  529.         print("What is the name of your thirteenth floor?")
  530.         f13 = read()
  531.         config.writeVal("f13",f13)
  532.         print("What is the number of your thirteenth floor monitor?")
  533.         m13 = read()
  534.         config.writeVal("m13",m13)
  535.         config.save()
  536.     end
  537.    
  538.     if nof >= 14 then
  539.         term.clear()
  540.         term.setCursorPos(1, 1)
  541.         config.load("configs","server")
  542.         print("What is the name of your fourteenth floor?")
  543.         f14 = read()
  544.         config.writeVal("f14",f14)
  545.         print("What is the number of your fourteenth floor monitor?")
  546.         m14 = read()
  547.         config.writeVal("m14",m14)
  548.         config.save()
  549.     end
  550.    
  551.     if nof >= 15 then
  552.         term.clear()
  553.         term.setCursorPos(1, 1)
  554.         config.load("configs","server")
  555.         print("What is the name of your fifteenth floor?")
  556.         f15 = read()
  557.         config.writeVal("f15",f15)
  558.         print("What is the number of your fifteenth floor monitor?")
  559.         m15 = read()
  560.         config.writeVal("m15",m15)
  561.         config.save()
  562.     end
  563.    
  564.     if nof >= 16 then
  565.         term.clear()
  566.         term.setCursorPos(1, 1)
  567.         config.load("configs","server")
  568.         print("What is the name of your sixteenth floor?")
  569.         f16 = read()
  570.         config.writeVal("f16",f16)
  571.         print("What is the number of your sixteenth floor monitor?")
  572.         m16 = read()
  573.         config.writeVal("m16",m16)
  574.         config.save()
  575.     end
  576.  
  577. fs.delete("server.lua")
  578. if not shell.run("pastebin", "get", "kULurzKm", "server.lua") then
  579. print("A error occurred, please try again!")
  580. return
  581. end
  582.  
  583. file = io.open("/startup", "w")
  584. file:write("shell.run(\"/"..shell.resolve(".").."/server.lua\")")
  585. file:close()
  586. term.write("Done")
  587. term.clear()
  588. term.setCursorPos(1, 1)
  589. print("Setup is complete press any key to reboot")
  590. os.pullEvent("key")
  591. os.reboot()
  592.  
  593. else
  594.     print("This program only supports 16 floors")
  595.     print("please re-run this script and try again")
  596. end
  597. else
  598.     print("You need at least 2 floors")
  599.     print("please re-run this script and try again")
  600. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement