BrineUtil

BrineUtil Installer for ComputerCraft

Dec 4th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.31 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("A project by KidBrine")
  4. sleep(0.5)
  5. print("Contributors")
  6. sleep(0.5)
  7. print("#1 Luca_S")
  8. sleep(3)
  9. InstallDir = ...
  10. if InstallDir == nil then InstallDir = 'BrineUtil' end
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. print('Do you wish to install BrineFormat? (Y/N)')
  14. local x = read()
  15.  
  16. if x == 'y' or x == 'Y' then
  17. local NF = fs.open(InstallDir..'/BrineFormat','w')
  18. NF.write(''
  19. ..'print("BrineFormat - By KidBrine")\n'
  20. ..'function TextBin(Concat,...)\n'
  21. ..'  T = {...}\n'
  22. ..'  if type(T[1]) == "table" then\n'
  23. ..'    T = T[1]\n'
  24. ..'  end\n'
  25. ..'  Ret = {}\n'
  26. ..'  for i = 1,#T do\n'
  27. ..'    ch = string.byte(T[i])\n'
  28. ..'    r = ""\n'
  29. ..'    local function chn(n)\n'
  30. ..'      if ch >= n then\n'
  31. ..'        ch = ch-n\n'
  32. ..'        r = r..1\n'
  33. ..'      else\n'
  34. ..'        r = r..0\n'
  35. ..'      end\n'
  36. ..'    end\n'
  37. ..'    chn(128) chn(64) chn(32) chn(16)\n'
  38. ..'    chn(8) chn(4) chn(2) chn(1)\n'
  39. ..'    chn = nil\n'
  40. ..'    table.insert(Ret,r)\n'
  41. ..'  end\n'
  42. ..'  if Concat == true then\n'
  43. ..'    NRET = ""\n'
  44. ..'    for i = 1,#Ret do\n'
  45. ..'      NRET = NRET..Ret[i]\n'
  46. ..'    end\n'
  47. ..'    Ret = NRET\n'
  48. ..'  end  \n'
  49. ..'  return Ret\n'
  50. ..'end\n'
  51. ..' \n'
  52. ..'function BinText(Concat,...)\n'
  53. ..'  T = {...}\n'
  54. ..'  if type(T[1]) == "table" then\n'
  55. ..'    T = T[1]\n'
  56. ..'  end\n'
  57. ..'  Ret = {}\n'
  58. ..'  for i = 1,#T do\n'
  59. ..'    r = string.char(tonumber(T[i],2))\n'
  60. ..'    table.insert(Ret,r)\n'
  61. ..'  end\n'
  62. ..'  if Concat == true then\n'
  63. ..'    NRET = ""\n'
  64. ..'    for i = 1,#Ret do\n'
  65. ..'      NRET = NRET..Ret[i]\n'
  66. ..'    end\n'
  67. ..'    Ret = NRET\n'
  68. ..'  end\n'
  69. ..'  return Ret\n'
  70. ..'end\n'
  71. ..'\n'
  72. ..'function StrTbl(str,ChrSet)\n'
  73. ..'  if type(str) ~= "string" then\n'
  74. ..'    error("String expected, got "..type(str)..".", 2)\n'
  75. ..'  end\n'
  76. ..'  repeat\n'
  77. ..'    if string.len(str)/ChrSet ~= math.floor(string.len(str)/ChrSet) then\n'
  78. ..'      str = str.." "\n'
  79. ..'    end\n'
  80. ..'  until string.len(str)/ChrSet == math.floor(string.len(str)/ChrSet)\n'
  81. ..'  Length = string.len(str)\n'
  82. ..'  Output = {}\n'
  83. ..'  for i = 1,Length/ChrSet do\n'
  84. ..'    NC = string.sub(str,1,ChrSet)\n'
  85. ..'    str = string.sub(str,ChrSet+1,string.len(str))\n'
  86. ..'    table.insert(Output,NC)\n'
  87. ..'  end\n'
  88. ..'  return Output\n'
  89. ..'end\n'
  90. ..'\n'
  91. ..'function TblStr(...)\n'
  92. ..'  T = {...}\n'
  93. ..'  Opt = ""\n'
  94. ..'  for i = 1, #T do\n'
  95. ..' Opt = Opt..table.concat(T[i])\n'
  96. ..'  end\n'
  97. ..'  return Opt\n'
  98. ..'end\n'
  99. ..'\n'
  100. ..'function SwapVars(V1,V2)\n'
  101. ..'  NV1 = V2\n'
  102. ..'  NV2 = V1\n'
  103. ..'  return NV1, NV2\n'
  104. ..'end\n'
  105. )
  106. NF.close()
  107. end
  108.  
  109.  
  110.  
  111.  
  112.  
  113. InstallDir = ...
  114. if InstallDir == nil then InstallDir = 'BrineUtil' end
  115. term.clear()
  116. term.setCursorPos(1,1)
  117. print('Do you wish to install BrineMath? (Y/N)')
  118. local x = read()
  119.  
  120. if x == 'y' or x == 'Y' then
  121. local NF = fs.open(InstallDir..'/BrineMath','w')
  122. NF.write(''
  123. ..'print("BrineMath - By KidBrine")\n'
  124. ..'function Root(R,N)\n'
  125. ..'  if type(N) ~= "number" or type(R) ~= "number" then\n'
  126. ..'    error("Number Expected.",2)\n'
  127. ..'  else\n'
  128. ..'    N = N^(1/R)\n'
  129. ..'  end\n'
  130. ..'  return N\n'
  131. ..'end\n'
  132. ..'\n'
  133. ..'function CircArea(R)\n'
  134. ..'  if type(R) ~= "number" then\n'
  135. ..'    error("Number Expected.")\n'
  136. ..'  else\n'
  137. ..'    R = math.pi*R^2\n'
  138. ..'  end\n'
  139. ..'  return R\n'
  140. ..'end\n'
  141. ..'\n'
  142. ..'function Average(...)\n'
  143. ..'  N = {...}\n'
  144. ..'  for i = 1,#N do\n'
  145. ..'    if type(N[i]) ~= "number" then\n'
  146. ..'      error("Arguments Can Only Be Numbers.",2)\n'
  147. ..'      break\n'
  148. ..'    end\n'
  149. ..'  end\n'
  150. ..'  NN = 0\n'
  151. ..'  for i = 1,#N do\n'
  152. ..'    NN = NN+N[i]\n'
  153. ..'  end\n'
  154. ..'  N = NN/#N\n'
  155. ..'  return N\n'
  156. ..'end\n'
  157. ..'\n'
  158. ..'function Circumference(R)\n'
  159. ..'  if type(R) ~= "number" then\n'
  160. ..'    error("Number Expected.")\n'
  161. ..'  else\n'
  162. ..'    R = 2*math.pi*R\n'
  163. ..'  end\n'
  164. ..'  return R\n'
  165. ..'end\n'
  166. ..'function InjectMath()\n'
  167. ..'  math.Root = BrineMath.Root\n'
  168. ..'  math.CircArea = BrineMath.CircArea \n'
  169. ..'  math.Average = BrineMath.Average\n'
  170. ..'  math.Circumference = BrineMath.Circumference\n'
  171. ..'end\n'
  172. ..'\n'
  173. ..'function ExtractMath()\n'
  174. ..'  math.Root = nil\n'
  175. ..'  math.CircArea = nil\n'
  176. ..'  math.Average = nil\n'
  177. ..'  math.Circumference = nil\n'
  178. ..'end\n'
  179. )
  180. NF.close()
  181. end
  182.  
  183.  
  184.  
  185.  
  186.  
  187. InstallDir = ...
  188. if InstallDir == nil then InstallDir = 'BrineUtil' end
  189. term.clear()
  190. term.setCursorPos(1,1)
  191. print('Do you wish to install BrinePeripheral? (Y/N)')
  192. local x = read()
  193.  
  194. if x == 'y' or x == 'Y' then
  195. local NF = fs.open(InstallDir..'/BrinePeripheral','w')
  196. NF.write(''
  197. ..'function ListType(T)\n'
  198. ..'  V1 = peripheral.getNames()\n'
  199. ..'  R = {}\n'
  200. ..'  for i = 1,#V1 do\n'
  201. ..'    if peripheral.getType(V1[i]) == T then\n'
  202. ..'      table.insert(R,peripheral.wrap(V1[i]))\n'
  203. ..' end\n'
  204. ..'  end\n'
  205. ..'  return R\n'
  206. ..'end\n'
  207. )
  208. NF.close()
  209. end
  210.  
  211.  
  212.  
  213.  
  214.  
  215. InstallDir = ...
  216. if InstallDir == nil then InstallDir = 'BrineUtil' end
  217. term.clear()
  218. term.setCursorPos(1,1)
  219. print('Do you wish to install BrinePic? (Y/N)')
  220. local x = read()
  221.  
  222. if x == 'y' or x == 'Y' then
  223. local NF = fs.open(InstallDir..'/BrinePic','w')
  224. NF.write(''
  225. ..'print("BrinePic - By KidBrine")\n'
  226. ..'function Draw(I,x,y)\n'
  227. ..'  if not fs.find(I) then\n'
  228. ..'    error("Could Not Find Image.",2)\n'
  229. ..'  end\n'
  230. ..'  if x == nil or y == nil then\n'
  231. ..'    x, y = term.getCursorPos()\n'
  232. ..'  end\n'
  233. ..'  I = paintutils.loadImage(I)\n'
  234. ..'  paintutils.drawImage(I,x,y)\n'
  235. ..'  term.setBackgroundColor(32768)\n'
  236. ..'end\n'
  237. ..'\n'
  238. ..'function CenterImage(I)\n'
  239. ..'  Im = paintutils.loadImage(I)\n'
  240. ..'  l,w = term.getSize()\n'
  241. ..'  y = math.ceil((w-#Im)/2)+1\n'
  242. ..'  cp1,cp2 = term.getCursorPos()\n'
  243. ..'  x = math.ceil((l-#Im[1])/2)+1  \n'
  244. ..'  Draw(I,x,y)\n'
  245. ..'end\n'
  246. )
  247. NF.close()
  248. end
  249.  
  250.  
  251.  
  252.  
  253.  
  254. InstallDir = ...
  255. if InstallDir == nil then InstallDir = 'BrineUtil' end
  256. term.clear()
  257. term.setCursorPos(1,1)
  258. print('Do you wish to install BrineText? (Y/N)')
  259. local x = read()
  260.  
  261. if x == 'y' or x == 'Y' then
  262. local NF = fs.open(InstallDir..'/BrineText','w')
  263. NF.write(''
  264. ..'print("BrineText - By KidBrine")\n'
  265. ..'function WritePos(T,x,y)\n'
  266. ..'  if type(T) ~= "string" then\n'
  267. ..'    error("First Argument Must Be a String.",2)\n'
  268. ..'  end\n'
  269. ..'  if type(x) ~= "number" or  type(y) ~= "number" then\n'
  270. ..'    error("Second and Third Argument Must Be Numbers.",2)\n'
  271. ..'  end\n'
  272. ..'  ox, oy = term.getCursorPos()\n'
  273. ..'  term.setCursorPos(x,y)\n'
  274. ..'  term.write(T)\n'
  275. ..'  term.setCursorPos(ox,oy)\n'
  276. ..'end\n'
  277. )
  278. NF.close()
  279. end
  280.  
  281.  
  282.  
  283.  
  284.  
  285. InstallDir = ...
  286. if InstallDir == nil then InstallDir = 'BrineUtil' end
  287. term.clear()
  288. term.setCursorPos(1,1)
  289. print('Do you wish to install Contributors.txt? (Y/N)')
  290. local x = read()
  291.  
  292. if x == 'y' or x == 'Y' then
  293. local NF = fs.open(InstallDir..'/Contributors.txt','w')
  294. NF.write(''
  295. ..'--#1 Luca_S - "I would suggest using varargs for\n'
  296. ..'--             the average function."\n'
  297. )
  298. NF.close()
  299. end
  300.  
  301.  
  302.  
  303.  
  304.  
  305. InstallDir = ...
  306. if InstallDir == nil then InstallDir = 'BrineUtil' end
  307. term.clear()
  308. term.setCursorPos(1,1)
  309. print('Do you wish to install LoadAPIS? (Y/N)')
  310. local x = read()
  311.  
  312. if x == 'y' or x == 'Y' then
  313. local NF = fs.open(InstallDir..'/LoadAPIS','w')
  314. NF.write(''
  315. ..'BrineUtil = {}\n'
  316. ..'BrineUtil.InstallDir = "/"..fs.getDir(shell.getRunningProgram())\n'
  317. ..'local APIS = fs.list(BrineUtil.InstallDir)\n'
  318. ..'for i = 1,#APIS do\n'
  319. ..'  if APIS[i] ~= "LoadAPIS" then\n'
  320. ..'    os.loadAPI("/"..BrineUtil.InstallDir.."/"..APIS[i])\n'
  321. ..'  end\n'
  322. ..'end\n'
  323. ..'\n'
  324. ..'-- BrineUtil functions\n'
  325. ..'function BrineUtil.Update()\n'
  326. ..'  fs.delete(BrineUtil.InstallDir)\n'
  327. ..'  shell.run("pastebin run t0aw2K2m "..BrineUtil.InstallDir)\n'
  328. ..'  shell.run(BrineUtil.InstallDir.."/LoadAPIS")\n'
  329. ..'end\n'
  330. ..'\n'
  331. ..'function BrineUtil.Uninstall()\n'
  332. ..'  print("Do you wish to uninstalll BrineUtil?(Yee Yee/Nay Nay)")\n'
  333. ..'  if read() == "Yee Yee" then\n'
  334. ..'    fs.delete(BrineUtil.InstallDir)\n'
  335. ..' print("To finish uninstalling BrineUtil you must reboot.")\n'
  336. ..' print("Do you wish to reboot now?(Yee Yee/Nay Nay)")\n'
  337. ..' if read() == "Yee Yee" then\n'
  338. ..'   os.reboot()\n'
  339. ..' end\n'
  340. ..'  end\n'
  341. ..'end\n'
  342. ..'\n'
  343. ..'function BrineUtil.VersionCheck()\n'
  344. ..'  print("BrineUtil: Ver 5.4")\n'
  345. ..'  print("BrineMath: Ver 4.2")\n'
  346. ..'  print("BrineFormat: Ver 2.6")\n'
  347. ..'  print("BrineText: Ver 4.0")\n'
  348. ..'  print("BrinePic: Ver 1.0")\n'
  349. ..'end\n'
  350. )
  351. NF.close()
  352. end
Advertisement
Add Comment
Please, Sign In to add comment