Advertisement
9551

buttonh backup

Jul 3rd, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.05 KB | None | 0 0
  1. --------------------------Buttonh----------------------
  2. ----------------------MENU/PANEL API-------------------
  3. --------------------by elektrobom1!--------------------
  4. ---Copyright (c) 2021-2022 9551------------9551#0001---
  5. ---using this code in your project is fine!------------
  6. ---as long as you dont claim you made it---------------
  7. ---im cool with it, feel free to include---------------
  8. ---in your projects! discord: 9551#0001--------------
  9. ---you dont have to but giving credits is nice :)------
  10. -------------------------------------------------------
  11. -------------------------------------------------------
  12. --to use this API do local var = require("button").terminal/monitor
  13. --*! pastebin get LTDZZZEJ button
  14.  
  15. --*functions usages
  16. --*API(ins, cord1, cord2, length, height)
  17. --*timetouch(timeout,monitor)
  18. --*touch()
  19. --*button(monitor, ins, cord1, cord2, text)
  20. --*counter(monitor, ins, cc, cord1, cord2, cv, max, min, col)
  21. --*fill(monitor, pos1, pos2, length, height)
  22. --*switch(monitor, ccins, pos1, pos2, col1, col2, col3, text)
  23. --*switchn(monitor, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  24. --*bundle(side, color, state)
  25. --*signal(side, ins, col)
  26. --*sliderVer/Hor(monitor, ins, cc, pos1, pos2, length, color1, textCol)
  27. --*local function menu(monitor, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2) (returns menuout)
  28. --*bar(monitor, pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
  29. --*timeswitch(monitor, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  30. --*render(monitor,text,x,y,textcol,backCol)
  31. --*menudata()
  32. --*frame(monitor, pos1, pos2, length, height, color3, color1, thicc)
  33. --*db allows you to get stored data from all functions that use stored data!
  34. --*how to use db: in your function for example switch you do b.switch("db",<data>) data is the storing position you want to get data of
  35.  
  36. --base API this API is made for detecting clicks in an area
  37. local monitor = {}
  38. local terminal = {}
  39. function monitor.API(ins, cord1, cord2, length, height)
  40. if ins == true then
  41. ins = {os.pullEvent("monitor_touch")}
  42. end
  43. if ins[3] >= cord1 and ins[3] <= cord1 + length - 1 then
  44. if ins[4] >= cord2 and ins[4] <= cord2 + height - 1 then
  45. return true
  46. else
  47. return false
  48. end
  49. end
  50. end
  51.  
  52. function monitor.touch()
  53. local dats = {os.pullEvent("monitor_touch")}
  54. return dats
  55. end
  56.  
  57. function monitor.timetouch(timeout, mon)
  58. local timer = os.startTimer(timeout)
  59. while true do
  60. local event = {os.pullEvent()}
  61. if (event[1] == "timer") and (event[2] == timer) then
  62. if mon == nil then
  63. local mon = "timeout"
  64. end
  65. return {"timeout", mon, 1000, 1000}
  66. elseif (event[1] == "monitor_touch") and (event[2] == mon) then
  67. return {event[1], event[2], event[3], event[4]}
  68. end
  69. end
  70. end
  71.  
  72. -------------------------------------------------------------------------------------------------
  73.  
  74. function monitor.button(mon, ins, cord1, cord2, text)
  75. if ins[2] == mon then
  76. if ins ~= nil then
  77. m = peripheral.wrap(mon)
  78. x = monitor.API(ins, cord1, cord2, string.len(text), 1)
  79. m.setCursorPos(cord1, cord2)
  80. m.write(text)
  81. return x
  82. end
  83. end
  84. end
  85.  
  86. function monitor.counter(mon, ins, cc, cord1, cord2, cv, max, min, col)
  87. if mon == "db" then
  88. if data == nil then
  89. return nil
  90. else
  91. return data[ins]
  92. end
  93. end
  94. if mon == "setdb" then
  95. if data == nil then
  96. return "no data to edit"
  97. else
  98. data[ins] = cc
  99. return ("value changed too " .. type(cc))
  100. end
  101. end
  102. if ins[2] == mon then
  103. if ins ~= nil then
  104. local m = peripheral.wrap(mon)
  105. if data == nil then
  106. data = {}
  107. for is = 0, 1000 do
  108. data[is] = 0
  109. end
  110. end
  111. m.setCursorPos(cord1, cord2)
  112. m.write("\24" .. " " .. data[cc])
  113. m.setCursorPos(cord1, cord2 + 1)
  114. m.write("\25")
  115. if monitor.API(ins, cord1, cord2, 1, 1) == true then
  116. if data[cc] < max then
  117. data[cc] = data[cc] + cv
  118. m.setCursorPos(cord1, cord2)
  119. m.setTextColor(colors.green)
  120. m.write("\24" .. " " .. data[cc] .. " ")
  121. m.setCursorPos(cord1, cord2 + 1)
  122. m.setTextColor(colors.red)
  123. m.write("\25")
  124. m.setTextColor(colors[col])
  125. return data[cc]
  126. end
  127. end
  128. end
  129. if monitor.API(ins, cord1, cord2 + 1, 1, 1) == true then
  130. if data[cc] > min then
  131. data[cc] = data[cc] - cv
  132. m.setCursorPos(cord1, cord2)
  133. m.setTextColor(colors.green)
  134. m.write("\24" .. " " .. data[cc] .. " ")
  135. m.setCursorPos(cord1, cord2 + 1)
  136. m.setTextColor(colors.red)
  137. m.write("\25")
  138. m.setTextColor(colors[col])
  139. return data[cc]
  140. end
  141. end
  142. end
  143. end
  144.  
  145. function monitor.fill(mon, pos1, pos2, length, height)
  146. local m = peripheral.wrap(mon)
  147. for x = 0, height - 1 do
  148. m.setCursorPos(pos1, pos2 + x)
  149. m.write(string.rep(" ", length))
  150. end
  151. end
  152.  
  153. function monitor.switch(mon, cc, ins, pos1, pos2, col1, col2, col3, text)
  154. if mon == "db" then
  155. if data1 == nil then
  156. return nil
  157. else
  158. return data1[cc]
  159. end
  160. end
  161. if mon == "setdb" then
  162. if data1 == nil then
  163. return "no data to edit"
  164. else
  165. data1[cc] = ins
  166. return ("value changed too " .. type(ins))
  167. end
  168. end
  169. if ins[2] == mon then
  170. if ins ~= nil then
  171. local re = string.len(text)
  172. local m = peripheral.wrap(mon)
  173. if data1 == nil then
  174. data1 = {}
  175. for is = 0, 1000 do
  176. data1[is] = false
  177. end
  178. end
  179. local function ff()
  180. data1[cc] = not data1[cc]
  181. end
  182. if monitor.API(ins, pos1, pos2, string.len(text), 1) == true then
  183. ff()
  184. end
  185. local oldcol1 = m.getTextColor()
  186. local oldcol2 = m.getBackgroundColor()
  187. if data1[cc] == true then
  188. m.setBackgroundColor(colors[col2])
  189. else
  190. m.setBackgroundColor(colors[col1])
  191. end
  192. m.setCursorPos(pos1, pos2)
  193. m.setTextColor(colors[col3])
  194. m.write(text)
  195. m.setTextColor(oldcol1)
  196. m.setBackgroundColor(oldcol2)
  197. return (data1[cc])
  198. end
  199. end
  200. end
  201.  
  202. function monitor.switchn(mon, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  203. if mon == "db" then
  204. if data2 == nil then
  205. return nil
  206. else
  207. return data2[cc]
  208. end
  209. end
  210. if mon == "setdb" then
  211. if data2 == nil then
  212. return "no data to edit"
  213. else
  214. data2[cc] = ins
  215. return ("value changed too " .. type(ins))
  216. end
  217. end
  218.  
  219. if ins[2] == mon then
  220. if ins ~= nil then
  221. local re = string.len(text)
  222. if string.len(text) ~= string.len(text2) then
  223. if string.len(text) > string.len(text2) then
  224. re = string.len(text)
  225. else
  226. re = string.len(text2)
  227. end
  228. end
  229. local m = peripheral.wrap(mon)
  230. if data2 == nil then
  231. data2 = {}
  232. for is = 0, 1000 do
  233. data2[is] = false
  234. end
  235. end
  236. local function ff()
  237. data2[cc] = not data2[cc]
  238. end
  239. if monitor.API(ins, pos1, pos2, re, 1) == true then
  240. ff()
  241. end
  242. local oldcol1 = m.getTextColor()
  243. local oldcol2 = m.getBackgroundColor()
  244. if data2[cc] == true then
  245. m.setCursorPos(pos1, pos2)
  246. if string.len(text) ~= string.len(text2) then
  247. m.write(string.rep(" ", re))
  248. end
  249. m.setBackgroundColor(colors[col2])
  250. m.setCursorPos(pos1, pos2)
  251. m.setTextColor(colors[col3])
  252. m.write(text2)
  253. else
  254. m.setCursorPos(pos1, pos2)
  255. if string.len(text) ~= string.len(text2) then
  256. m.write(string.rep(" ", re))
  257. end
  258. m.setBackgroundColor(colors[col1])
  259. m.setCursorPos(pos1, pos2)
  260. m.setTextColor(colors[col3])
  261. m.write(text)
  262. end
  263. m.setTextColor(oldcol1)
  264. m.setBackgroundColor(oldcol2)
  265. return (data2[cc])
  266. end
  267. end
  268. end
  269. -- bundle cable APIs for using main API with bundled cables
  270. function monitor.bundle(side, color, state)
  271. if (type(side) == "string") and (type(color) == "number") and (type(state) == "boolean") then
  272. if state == true then
  273. rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
  274. elseif state == false then
  275. rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
  276. end
  277. else
  278. error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")
  279. end
  280. end
  281.  
  282. function monitor.signal(side, ins, col, func)
  283. if ins == "clear" then
  284. rs.setBundledOutput(side, 0)
  285. else
  286. if func == true then
  287. if ins == "on" then
  288. ins = true
  289. end
  290. if ins == "nil" then
  291. ins = false
  292. end
  293. end
  294. if ins ~= nil then
  295. if ins == true then
  296. bundle(side, col, true)
  297. elseif ins == false then
  298. bundle(side, col, false)
  299. end
  300. end
  301. end
  302. end
  303. -------------------------------------------------------------------------------------------------
  304.  
  305. function monitor.sliderHor(mon, ins, cc, pos1, pos2, length, color1, textCol)
  306. if mon == "db" then
  307. if data3 == nil then
  308. return nil
  309. else
  310. return data3[ins]
  311. end
  312. end
  313. if mon == "setdb" then
  314. if data3 == nil then
  315. return "no data to edit"
  316. else
  317. data3[ins] = cc
  318. return ("value changed too " .. type(cc))
  319. end
  320. end
  321. if ins[2] == mon then
  322. if ins ~= nil then
  323. m = peripheral.wrap(mon)
  324. local oldcol1 = m.getBackgroundColor()
  325. local oldcol2 = m.getTextColor()
  326. m.setBackgroundColor(colors[color1])
  327. m.setTextColor(colors[textCol])
  328. m.setCursorPos(pos1, pos2)
  329. for i = 0, length do
  330. m.write("-")
  331. m.setCursorPos(pos1 + i, pos2)
  332. end
  333. if data3 == nil then
  334. data3 = {}
  335. for is = 0, 1000 do
  336. data3[is] = 0
  337. end
  338. end
  339. local cp = (ins[3])
  340. if (ins[4] == pos2) and (ins[3] >= pos1) and (ins[3] <= (pos1 + length) - 1) then
  341. m.setCursorPos(cp, pos2)
  342. data3[cc] = cp
  343. m.write("|")
  344. else
  345. m.setCursorPos(data3[cc], pos2)
  346. m.write("|")
  347. end
  348. m.setBackgroundColor(oldcol1)
  349. m.setTextColor(oldcol2)
  350. if data3[cc] - pos1 >= 0 then
  351. return (data3[cc] - pos1)
  352. elseif data3[cc] - pos1 < 0 then
  353. return 0
  354. end
  355. end
  356. end
  357. end
  358.  
  359. function monitor.sliderVer(mon, ins, cc, pos1, pos2, length, color1, textCol)
  360. if mon == "db" then
  361. if data10 == nil then
  362. return nil
  363. else
  364. return data10[ins]
  365. end
  366. end
  367. if mon == "setdb" then
  368. if data10 == nil then
  369. return "no data to edit"
  370. else
  371. data10[ins] = cc
  372. return ("value changed too " .. type(cc))
  373. end
  374. end
  375. if ins[2] == mon then
  376. if ins ~= nil then
  377. m = peripheral.wrap(mon)
  378. local oldcol1 = m.getBackgroundColor()
  379. local oldcol2 = m.getTextColor()
  380. m.setBackgroundColor(colors[color1])
  381. m.setTextColor(colors[textCol])
  382. m.setCursorPos(pos1, pos2)
  383. for i = 0, length do
  384. m.write("\124")
  385. m.setCursorPos(pos1, pos2 - i)
  386. end
  387. if data10 == nil then
  388. data10 = {}
  389. for is = 0, 1000 do
  390. data10[is] = 0
  391. end
  392. end
  393. local cp = ins[4]
  394. if (ins[3] == pos1) and (ins[4] <= pos2) and (ins[4] >= (pos2 - length) + 1) then
  395. m.setCursorPos(pos1, cp)
  396. data10[cc] = cp
  397. m.write("\xad")
  398. else
  399. m.setCursorPos(pos1, data10[cc])
  400. m.write("\xad")
  401. end
  402. m.setBackgroundColor(oldcol1)
  403. m.setTextColor(oldcol2)
  404. if data10[cc] - pos1 >= 0 then
  405. return (data10[cc] - pos1)
  406. elseif data10[cc] - pos1 < 0 then
  407. return 0
  408. end
  409. end
  410. end
  411. end
  412.  
  413. function monitor.render(mon, text, x, y, textcol, backCol)
  414. local m = peripheral.wrap(mon)
  415. local oldcol1 = m.getBackgroundColor()
  416. local oldcol2 = m.getTextColor()
  417. local cur = {m.getCursorPos()}
  418. m.setTextColor(colors[textcol])
  419. if type(backCol) == "string" then
  420. m.setBackgroundColor(colors[backCol])
  421. elseif type(backCol) == "number" then
  422. m.setBackgroundColor(backCol)
  423. end
  424. m.setCursorPos(x, y)
  425. m.write(text)
  426. m.setBackgroundColor(oldcol1)
  427. m.setTextColor(oldcol2)
  428. m.setCursorPos(cur[1], cur[2])
  429. end
  430.  
  431. function monitor.menu(mon, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)
  432. if ins[2] == mon then
  433. if thisIsUseless == nil then
  434. for i = 0, 1000 do
  435. thisIsUseless = {}
  436. thisIsUseless[i] = false
  437. end
  438. end
  439. if not thisIsUseless[cc] then
  440. monitor.render(mon, text, x, y, textcol, oldcol2)
  441. end
  442. if ins ~= nil then
  443. local m = peripheral.wrap(mon)
  444. local oldcol1 = m.getTextColor()
  445. local oldcol2 = m.getBackgroundColor()
  446. local l = string.len(text)
  447. if ins[1] ~= "timeout" then
  448. if data4 == nil then
  449. data4 = {}
  450. for is = 0, 1000 do
  451. data4[is] = false
  452. end
  453. end
  454. if data5 == nil then
  455. data5 = {}
  456. for is = 0, 1000 do
  457. data5[is] = false
  458. end
  459. end
  460. if data6 == nil then
  461. data6 = {}
  462. for is = 0, 1000 do
  463. data6[is] = false
  464. end
  465. end
  466. if monitor.API(ins, x, y, l, 1) == true then
  467. data4[cc] = text
  468. data5[cc] = x
  469. data6[cc] = y
  470. local function menus()
  471. for i = 1, 500 do
  472. if data4[i] ~= false then
  473. m.setBackgroundColor(oldcol2)
  474. m.setCursorPos(data5[i], data6[i])
  475. m.setTextColor(colors[textcol])
  476. m.write(data4[i])
  477. end
  478. end
  479. local i = 0
  480. end
  481. menus()
  482. m.setCursorPos(data5[cc], data6[cc])
  483. m.setBackgroundColor(colors[switchcol])
  484. m.setTextColor(colors[textcol])
  485. m.write(text)
  486. m.setTextColor(oldcol1)
  487. m.setBackgroundColor(oldcol2)
  488. menuout = text
  489. if returns1 == nil then
  490. return menuout
  491. else
  492. if (more == nil) or (more == false) then
  493. menuout = returns1
  494. return menuout
  495. else
  496. menuout = {
  497. returns1,
  498. returns2
  499. }
  500. if menuout == nil then
  501. return 0
  502. end
  503. return menuout
  504. end
  505. end
  506. end
  507. end
  508. end
  509. end
  510. thisIsUseless[cc] = true
  511. if more == true then
  512. if menuout == nil then
  513. menuout = {returns1, "nil"}
  514. end
  515. end
  516. end
  517.  
  518. function monitor.menudata()
  519. if menuout ~= nil then
  520. return menuout
  521. else
  522. return "no output"
  523. end
  524. end
  525.  
  526. function monitor.timeswitch(mon, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  527. if mon == "db" then
  528. if data7 == nil then
  529. return nil
  530. else
  531. return data7[ins]
  532. end
  533. end
  534. if mon == "setdb" then
  535. if data7 == nil then
  536. return "no data to edit"
  537. else
  538. data7[ins] = cc
  539. return ("value changed too " .. type(cc))
  540. end
  541. end
  542. if ins[2] == mon then
  543. if ins ~= nil then
  544. local m = peripheral.wrap(mon)
  545. local oldcol1 = m.getTextColor()
  546. local oldcol2 = m.getBackgroundColor()
  547. m.setBackgroundColor(colors[col2])
  548. m.setTextColor(colors[col1])
  549. if data7 == nil then
  550. data7 = {}
  551. for is = 0, 1000 do
  552. data7[is] = false
  553. end
  554. end
  555. if data8 == nil then
  556. data8 = {}
  557. for is = 0, 1000 do
  558. data8[is] = false
  559. end
  560. end
  561. if data8[cc] == false then
  562. data8[cc] = start
  563. m.setCursorPos(pos1 + 6, pos2)
  564. m.write(data8[cc])
  565. end
  566. m.setCursorPos(pos1, pos2)
  567. m.write("start")
  568. if monitor.API(ins, pos1, pos2, 4, 1) == true then
  569. data7[cc] = true
  570. end
  571. if data7[cc] == true then
  572. if data8[cc] > 0 then
  573. repeat
  574. timeOut = data8[cc]
  575. m.setBackgroundColor(colors[col3])
  576. data8[cc] = data8[cc] - change
  577. m.setCursorPos(pos1 + 6, pos2)
  578. sleep(1)
  579. m.write(data8[cc])
  580. until data8[cc] == 0
  581. return "ended"
  582. end
  583. end
  584. if repeats == true then
  585. data8[cc] = start
  586. end
  587. m.setBackgroundColor(colors[col2])
  588. m.setCursorPos(pos1 + 6, pos2)
  589. m.write(data8[cc])
  590. m.setTextColor(oldcol1)
  591. m.setBackgroundColor(oldcol2)
  592. end
  593. end
  594. end
  595.  
  596. function monitor.bar(
  597. mon,
  598. pos1,
  599. pos2,
  600. length,
  601. height,
  602. ins,
  603. max,
  604. color1,
  605. color2,
  606. color3,
  607. printval,
  608. hor,
  609. text,
  610. format,
  611. rect,
  612. thicc)
  613. if (ins == nil) or (ins < 0) then
  614. ins = 0
  615. end
  616. if format == nil then
  617. local format = false
  618. end
  619. if ins ~= nil then
  620. local m = peripheral.wrap(mon)
  621. oldcol = m.getBackgroundColor()
  622. oldcol1 = m.getTextColor()
  623. m.setTextColor(colors[color3])
  624. local function reprint()
  625. m.setBackgroundColor(colors[color1])
  626. monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  627. m.setBackgroundColor(oldcol)
  628. xm = m.getBackgroundColor()
  629. xb = m.getTextColor()
  630. m.setTextColor(xm)
  631. m.setBackgroundColor(xb)
  632. m.setCursorPos(pos1 - 1, pos2 - height)
  633. if thicc then
  634. m.setBackgroundColor(colors[color3])
  635. end
  636. if thicc then
  637. m.write(string.rep("\x83", length + 1)) --\143
  638. m.setTextColor(xb)
  639. m.setBackgroundColor(xm)
  640. else
  641. m.write("\159" .. string.rep("\143", length - 1)) --\x83
  642. m.setTextColor(xb)
  643. m.setBackgroundColor(xm)
  644. m.write("\144")
  645. end
  646. if thicc then
  647. m.setBackgroundColor(colors[color3])
  648. end
  649. m.setCursorPos(pos1 - 1, pos2 + height)
  650. if thicc then
  651. m.write(string.rep("\x8c", length + 1)) --\131
  652. else
  653. m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  654. end
  655. for i = 0, (height * 2) - 2 do
  656. if not thicc then
  657. m.setTextColor(xm)
  658. m.setBackgroundColor(xb)
  659. end
  660. m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  661. if thicc then
  662. m.setBackgroundColor(colors[color3])
  663. end
  664. m.write("\x95")
  665. m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  666. if not thicc then
  667. m.setTextColor(xb)
  668. m.setBackgroundColor(xm)
  669. end
  670. m.write("\x95")
  671. end
  672. end
  673. if rect ~= false then
  674. reprint()
  675. else
  676. monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  677. end
  678. local drawLength = ins / max * length
  679. local drawHeights = ins / max * height
  680. local drawHeight = math.ceil(drawHeights)
  681. local moveval = (drawHeight * 2) - 2
  682. local z = pos2 + height
  683. m.setBackgroundColor(colors[color2])
  684. if (hor == false) or (hor == nil) then
  685. monitor.fill(mon, pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  686. else
  687. monitor.fill(mon, pos1, (z - 1) - moveval, length - 1, moveval + 1)
  688. end
  689. if printval == true then
  690. m.setCursorPos(pos1, pos2)
  691. m.setTextColor(colors[color3])
  692. if hor == true then
  693. if format then
  694. if ins >= max / 2 then
  695. m.setBackgroundColor(colors[color2])
  696. else
  697. m.setBackgroundColor(colors[color1])
  698. end
  699. else
  700. if ins >= (max / 2) - (max / height) then
  701. m.setBackgroundColor(colors[color2])
  702. else
  703. m.setBackgroundColor(colors[color1])
  704. end
  705. end
  706. elseif hor == false then
  707. m.setCursorPos(pos1, pos2)
  708. m.setTextColor(colors[color3])
  709. if hor == true then
  710. if ins >= 1 then
  711. m.setBackgroundColor(colors[color2])
  712. else
  713. m.setBackgroundColor(colors[color1])
  714. end
  715. end
  716. end
  717. if format then
  718. m.write(ins .. "/" .. max)
  719. m.setCursorPos(pos1, pos2 + 1)
  720. m.write(text)
  721. else
  722. m.write(ins .. "/" .. max .. " " .. text)
  723. end
  724. m.setBackgroundColor(oldcol)
  725. m.setTextColor(oldcol1)
  726. end
  727. m.setTextColor(oldcol1)
  728. m.setBackgroundColor(oldcol)
  729. end
  730. end
  731.  
  732. function monitor.frame(mon, pos1, pos2, length, height, color3, color1, thicc)
  733. local m = peripheral.wrap(mon)
  734. local oldcol = m.getBackgroundColor()
  735. local oldcol1 = m.getTextColor()
  736. m.setBackgroundColor(colors[color1])
  737. monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  738. m.setBackgroundColor(oldcol)
  739. xm = m.getBackgroundColor()
  740. xb = m.getTextColor()
  741. m.setTextColor(xm)
  742. m.setBackgroundColor(xb)
  743. m.setCursorPos(pos1 - 1, pos2 - height)
  744. if thicc then
  745. m.setBackgroundColor(colors[color3])
  746. m.setTextColor(oldcol)
  747. m.write(string.rep("\x83", length + 1)) --\143
  748. m.setTextColor(xb)
  749. m.setBackgroundColor(xm)
  750. else
  751. m.setTextColor(oldcol)
  752. m.setBackgroundColor(colors[color3])
  753. m.write("\159" .. string.rep("\143", length - 1)) --\x83
  754. m.setTextColor(colors[color3])
  755. m.setBackgroundColor(oldcol)
  756. m.write("\144")
  757. end
  758. m.setCursorPos(pos1 - 1, pos2 + height)
  759. if thicc then
  760. m.setBackgroundColor(oldcol)
  761. m.setTextColor(colors[color3])
  762. m.write(string.rep("\x8f", length + 1)) --\131
  763. m.setBackgroundColor(colors[color1])
  764. m.setTextColor(colors[color3])
  765. else
  766. m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  767. end
  768. for i = 0, (height * 2) - 2 do
  769. if not thicc then
  770. m.setTextColor(xm)
  771. m.setBackgroundColor(xb)
  772. end
  773. m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  774. if thicc then
  775. m.setBackgroundColor(colors[color3])
  776. end
  777. m.setBackgroundColor(colors[color3])
  778. m.write("\x95")
  779. m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  780. if not thicc then
  781. m.setTextColor(xb)
  782. m.setBackgroundColor(xm)
  783. end
  784. m.setTextColor(colors[color3])
  785. m.write("\x95")
  786. end
  787. m.setBackgroundColor(oldcol)
  788. m.setTextColor(oldcol1)
  789. end
  790.  
  791. --*functions usages
  792. --*API(ins, cord1, cord2, length, height)
  793. --*timetouch(timeout)
  794. --*touch()
  795. --*button(lr,ins, cord1, cord2, text)
  796. --*counter(lr, ins, cc, cord1, cord2, cv, max, min, col)
  797. --*fill(pos1, pos2, length, height)
  798. --*switch(lr, ccins, pos1, pos2, col1, col2, col3, text)
  799. --*switchn(lr, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  800. --*bundle(side, color, state)
  801. --*signal(side, ins, col)
  802. --*sliderVer/Hor(lr, ins, cc, pos1, pos2, length, color1, textCol)
  803. --*local function menu(lr, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2) (returns menuout)
  804. --*bar(pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
  805. --*timeswitch(lr, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  806. --*render(text,x,y,textcol,backCol)
  807. --*menudata()
  808. --*frame(pos1, pos2, length, height, color3, color1, thicc)
  809. --*db allows you to get stored data from all functions that use stored data!
  810. --*how to use db: in your function for example switch you do b.switch("db",<data>) data is the storing position you want to get data of
  811.  
  812. --base API this API is made for detecting clicks in an area
  813. function terminal.API(ins, cord1, cord2, length, height)
  814. if ins == true then
  815. ins = {os.pullEvent("mouse_click")}
  816. end
  817. if ins[3] >= cord1 and ins[3] <= cord1 + length - 1 then
  818. if ins[4] >= cord2 and ins[4] <= cord2 + height - 1 then
  819. return true
  820. else
  821. return false
  822. end
  823. end
  824. end
  825.  
  826. function terminal.touch()
  827. local dats = {os.pullEvent("mouse_click")}
  828. return dats
  829. end
  830.  
  831. function terminal.timetouch(timeout)
  832. local timer = os.startTimer(timeout)
  833. while true do
  834. local event = {os.pullEvent()}
  835. if (event[1] == "timer") and (event[2] == timer) then
  836. return {"timeout", "tout", 1000, 1000}
  837. elseif (event[1] == "mouse_click") then
  838. return {event[1], event[2], event[3], event[4]}
  839. end
  840. end
  841. end
  842.  
  843. -------------------------------------------------------------------------------------------------
  844.  
  845. function terminal.button(lr, ins, cord1, cord2, text)
  846. if ins[2] == lr or ins[2] == "tout" then
  847. if ins ~= nil then
  848. x = terminal.API(ins, cord1, cord2, string.len(text), 1)
  849. term.setCursorPos(cord1, cord2)
  850. term.write(text)
  851. return x
  852. end
  853. end
  854. end
  855.  
  856. function terminal.counter(lr, ins, cc, cord1, cord2, cv, max, min, col)
  857. if lr == "db" then
  858. if data == nil then
  859. return nil
  860. else
  861. return data[ins]
  862. end
  863. end
  864. if lr == "setdb" then
  865. if data == nil then
  866. return "no data to edit"
  867. else
  868. data[ins] = cc
  869. return ("value changed too " .. type(cc))
  870. end
  871. end
  872. if ins[2] == lr or ins[2] == "tout" then
  873. if ins ~= nil then
  874. if data == nil then
  875. data = {}
  876. for is = 0, 1000 do
  877. data[is] = 0
  878. end
  879. end
  880. term.setCursorPos(cord1, cord2)
  881. term.write("\24" .. " " .. data[cc])
  882. term.setCursorPos(cord1, cord2 + 1)
  883. term.write("\25")
  884. if terminal.API(ins, cord1, cord2, 1, 1) == true then
  885. if data[cc] < max then
  886. data[cc] = data[cc] + cv
  887. term.setCursorPos(cord1, cord2)
  888. term.setTextColor(colors.green)
  889. term.write("\24" .. " " .. data[cc] .. " ")
  890. term.setCursorPos(cord1, cord2 + 1)
  891. term.setTextColor(colors.red)
  892. term.write("\25")
  893. term.setTextColor(colors[col])
  894. return data[cc]
  895. end
  896. end
  897. end
  898. if terminal.API(ins, cord1, cord2 + 1, 1, 1) == true then
  899. if data[cc] > min then
  900. data[cc] = data[cc] - cv
  901. term.setCursorPos(cord1, cord2)
  902. term.setTextColor(colors.green)
  903. term.write("\24" .. " " .. data[cc] .. " ")
  904. term.setCursorPos(cord1, cord2 + 1)
  905. term.setTextColor(colors.red)
  906. term.write("\25")
  907. term.setTextColor(colors[col])
  908. return data[cc]
  909. end
  910. end
  911. end
  912. end
  913.  
  914. function terminal.fill(pos1, pos2, length, height)
  915. for x = 0, height - 1 do
  916. term.setCursorPos(pos1, pos2 + x)
  917. term.write(string.rep(" ", length))
  918. end
  919. end
  920.  
  921. function terminal.switch(lr, cc, ins, pos1, pos2, col1, col2, col3, text)
  922. if lr == "db" then
  923. if data1 == nil then
  924. return nil
  925. else
  926. return data1[cc]
  927. end
  928. end
  929. if lr == "setdb" then
  930. if data1 == nil then
  931. return "no data to edit"
  932. else
  933. data1[cc] = ins
  934. return ("value changed too " .. type(ins))
  935. end
  936. end
  937. if ins[2] == lr or ins[2] == "tout" then
  938. if ins ~= nil then
  939. local re = string.len(text)
  940. if data1 == nil then
  941. data1 = {}
  942. for is = 0, 1000 do
  943. data1[is] = false
  944. end
  945. end
  946. local function ff()
  947. data1[cc] = not data1[cc]
  948. end
  949. if terminal.API(ins, pos1, pos2, string.len(text), 1) == true then
  950. ff()
  951. end
  952. local oldcol1 = term.getTextColor()
  953. local oldcol2 = term.getBackgroundColor()
  954. if data1[cc] == true then
  955. term.setBackgroundColor(colors[col2])
  956. else
  957. term.setBackgroundColor(colors[col1])
  958. end
  959. term.setCursorPos(pos1, pos2)
  960. term.setTextColor(colors[col3])
  961. term.write(text)
  962. term.setTextColor(oldcol1)
  963. term.setBackgroundColor(oldcol2)
  964. return (data1[cc])
  965. end
  966. end
  967. end
  968.  
  969. function terminal.switchn(lr, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  970. if lr == "db" then
  971. if data2 == nil then
  972. return nil
  973. else
  974. return data2[cc]
  975. end
  976. end
  977. if lr == "setdb" then
  978. if data2 == nil then
  979. return "no data to edit"
  980. else
  981. data2[cc] = ins
  982. return ("value changed too " .. type(ins))
  983. end
  984. end
  985.  
  986. if ins[2] == lr or ins[2] == "tout" then
  987. if ins ~= nil then
  988. local re = string.len(text)
  989. if string.len(text) ~= string.len(text2) then
  990. if string.len(text) > string.len(text2) then
  991. re = string.len(text)
  992. else
  993. re = string.len(text2)
  994. end
  995. end
  996. if data2 == nil then
  997. data2 = {}
  998. for is = 0, 1000 do
  999. data2[is] = false
  1000. end
  1001. end
  1002. local function ff()
  1003. data2[cc] = not data2[cc]
  1004. end
  1005. if terminal.API(ins, pos1, pos2, re, 1) == true then
  1006. ff()
  1007. end
  1008. local oldcol1 = term.getTextColor()
  1009. local oldcol2 = term.getBackgroundColor()
  1010. if data2[cc] == true then
  1011. term.setCursorPos(pos1, pos2)
  1012. if string.len(text) ~= string.len(text2) then
  1013. term.write(string.rep(" ", re))
  1014. end
  1015. term.setBackgroundColor(colors[col2])
  1016. term.setCursorPos(pos1, pos2)
  1017. term.setTextColor(colors[col3])
  1018. term.write(text2)
  1019. else
  1020. term.setCursorPos(pos1, pos2)
  1021. if string.len(text) ~= string.len(text2) then
  1022. term.write(string.rep(" ", re))
  1023. end
  1024. term.setBackgroundColor(colors[col1])
  1025. term.setCursorPos(pos1, pos2)
  1026. term.setTextColor(colors[col3])
  1027. term.write(text)
  1028. end
  1029. term.setTextColor(oldcol1)
  1030. term.setBackgroundColor(oldcol2)
  1031. return (data2[cc])
  1032. end
  1033. end
  1034. end
  1035. -- bundle cable APIs for using main API with bundled cables
  1036. function terminal.bundle(side, color, state)
  1037. if (type(side) == "string") and (type(color) == "number") and (type(state) == "boolean") then
  1038. if state == true then
  1039. rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
  1040. elseif state == false then
  1041. rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
  1042. end
  1043. else
  1044. error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")
  1045. end
  1046. end
  1047.  
  1048. function terminal.signal(side, ins, col, func)
  1049. if ins == "clear" then
  1050. rs.setBundledOutput(side, 0)
  1051. else
  1052. if func == true then
  1053. if ins == "on" then
  1054. ins = true
  1055. end
  1056. if ins == "nil" then
  1057. ins = false
  1058. end
  1059. end
  1060. if ins ~= nil then
  1061. if ins == true then
  1062. bundle(side, col, true)
  1063. elseif ins == false then
  1064. bundle(side, col, false)
  1065. end
  1066. end
  1067. end
  1068. end
  1069. -------------------------------------------------------------------------------------------------
  1070.  
  1071. function terminal.sliderHor(lr, ins, cc, pos1, pos2, length, color1, textCol)
  1072. if lr == "db" then
  1073. if data3 == nil then
  1074. return nil
  1075. else
  1076. return data3[ins]
  1077. end
  1078. end
  1079. if lr == "setdb" then
  1080. if data3 == nil then
  1081. return "no data to edit"
  1082. else
  1083. data3[ins] = cc
  1084. return ("value changed too " .. type(cc))
  1085. end
  1086. end
  1087. if ins[2] == lr or ins[2] == "tout" then
  1088. if ins ~= nil then
  1089. local oldcol1 = term.getBackgroundColor()
  1090. local oldcol2 = term.getTextColor()
  1091. term.setBackgroundColor(colors[color1])
  1092. term.setTextColor(colors[textCol])
  1093. term.setCursorPos(pos1, pos2)
  1094. for i = 0, length do
  1095. term.write("-")
  1096. term.setCursorPos(pos1 + i, pos2)
  1097. end
  1098. if data3 == nil then
  1099. data3 = {}
  1100. for is = 0, 1000 do
  1101. data3[is] = 0
  1102. end
  1103. end
  1104. local cp = (ins[3])
  1105. if (ins[4] == pos2) and (ins[3] >= pos1) and (ins[3] <= (pos1 + length) - 1) then
  1106. term.setCursorPos(cp, pos2)
  1107. data3[cc] = cp
  1108. term.write("|")
  1109. else
  1110. term.setCursorPos(data3[cc], pos2)
  1111. term.write("|")
  1112. end
  1113. term.setBackgroundColor(oldcol1)
  1114. term.setTextColor(oldcol2)
  1115. if data3[cc] - pos1 >= 0 then
  1116. return (data3[cc] - pos1)
  1117. elseif data3[cc] - pos1 < 0 then
  1118. return 0
  1119. end
  1120. end
  1121. end
  1122. end
  1123.  
  1124. function terminal.sliderVer(lr, ins, cc, pos1, pos2, length, color1, textCol)
  1125. if lr == "db" then
  1126. if data10 == nil then
  1127. return nil
  1128. else
  1129. return data10[ins]
  1130. end
  1131. end
  1132. if lr == "setdb" then
  1133. if data10 == nil then
  1134. return "no data to edit"
  1135. else
  1136. data10[ins] = cc
  1137. return ("value changed too " .. type(cc))
  1138. end
  1139. end
  1140. if ins[2] == lr or ins[2] == "tout" then
  1141. if ins ~= nil then
  1142. local oldcol1 = term.getBackgroundColor()
  1143. local oldcol2 = term.getTextColor()
  1144. term.setBackgroundColor(colors[color1])
  1145. term.setTextColor(colors[textCol])
  1146. term.setCursorPos(pos1, pos2)
  1147. for i = 0, length do
  1148. term.write("\124")
  1149. term.setCursorPos(pos1, pos2 - i)
  1150. end
  1151. if data10 == nil then
  1152. data10 = {}
  1153. for is = 0, 1000 do
  1154. data10[is] = 0
  1155. end
  1156. end
  1157. local cp = ins[4]
  1158. if (ins[3] == pos1) and (ins[4] <= pos2) and (ins[4] >= (pos2 - length) + 1) then
  1159. term.setCursorPos(pos1, cp)
  1160. data10[cc] = cp
  1161. term.write("\xad")
  1162. else
  1163. term.setCursorPos(pos1, data10[cc])
  1164. term.write("\xad")
  1165. end
  1166. term.setBackgroundColor(oldcol1)
  1167. term.setTextColor(oldcol2)
  1168. if data10[cc] - pos1 >= 0 then
  1169. return (data10[cc] - pos1)
  1170. elseif data10[cc] - pos1 < 0 then
  1171. return 0
  1172. end
  1173. end
  1174. end
  1175. end
  1176.  
  1177. function terminal.render(text, x, y, textcol, backCol)
  1178. local oldcol1 = term.getBackgroundColor()
  1179. local oldcol2 = term.getTextColor()
  1180. local cur = {term.getCursorPos()}
  1181. term.setTextColor(colors[textcol])
  1182. if type(backCol) == "string" then
  1183. term.setBackgroundColor(colors[backCol])
  1184. elseif type(backCol) == "number" then
  1185. term.setBackgroundColor(backCol)
  1186. end
  1187. term.setCursorPos(x, y)
  1188. term.write(text)
  1189. term.setBackgroundColor(oldcol1)
  1190. term.setTextColor(oldcol2)
  1191. term.setCursorPos(cur[1], cur[2])
  1192. end
  1193.  
  1194. function terminal.menu(lr, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)
  1195. if ins[2] == lr or ins[2] == "tout" then
  1196. if thisIsUseless == nil then
  1197. for i = 0, 1000 do
  1198. thisIsUseless = {}
  1199. thisIsUseless[i] = false
  1200. end
  1201. end
  1202. if not thisIsUseless[cc] then
  1203. terminal.render(text, x, y, textcol, oldcol2)
  1204. end
  1205. if ins ~= nil then
  1206. local oldcol1 = term.getTextColor()
  1207. local oldcol2 = term.getBackgroundColor()
  1208. local l = string.len(text)
  1209. if ins[1] ~= "timeout" then
  1210. if data4 == nil then
  1211. data4 = {}
  1212. for is = 0, 1000 do
  1213. data4[is] = false
  1214. end
  1215. end
  1216. if data5 == nil then
  1217. data5 = {}
  1218. for is = 0, 1000 do
  1219. data5[is] = false
  1220. end
  1221. end
  1222. if data6 == nil then
  1223. data6 = {}
  1224. for is = 0, 1000 do
  1225. data6[is] = false
  1226. end
  1227. end
  1228. if terminal.API(ins, x, y, l, 1) == true then
  1229. data4[cc] = text
  1230. data5[cc] = x
  1231. data6[cc] = y
  1232. local function menus()
  1233. for i = 1, 500 do
  1234. if data4[i] ~= false then
  1235. term.setBackgroundColor(oldcol2)
  1236. term.setCursorPos(data5[i], data6[i])
  1237. term.setTextColor(colors[textcol])
  1238. term.write(data4[i])
  1239. end
  1240. end
  1241. local i = 0
  1242. end
  1243. menus()
  1244. term.setCursorPos(data5[cc], data6[cc])
  1245. term.setBackgroundColor(colors[switchcol])
  1246. term.setTextColor(colors[textcol])
  1247. term.write(text)
  1248. term.setTextColor(oldcol1)
  1249. term.setBackgroundColor(oldcol2)
  1250. menuout = text
  1251. if returns1 == nil then
  1252. return menuout
  1253. else
  1254. if (more == nil) or (more == false) then
  1255. menuout = returns1
  1256. return menuout
  1257. else
  1258. menuout = {
  1259. returns1,
  1260. returns2
  1261. }
  1262. if menuout == nil then
  1263. return 0
  1264. end
  1265. return menuout
  1266. end
  1267. end
  1268. end
  1269. end
  1270. end
  1271. end
  1272. thisIsUseless[cc] = true
  1273. if more == true then
  1274. if menuout == nil then
  1275. menuout = {returns1, "nil"}
  1276. end
  1277. end
  1278. end
  1279.  
  1280. function terminal.menudata()
  1281. if menuout ~= nil then
  1282. return menuout
  1283. else
  1284. return "no output"
  1285. end
  1286. end
  1287.  
  1288. function terminal.timeswitch(lr, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  1289. if lr == "db" then
  1290. if data7 == nil then
  1291. return nil
  1292. else
  1293. return data7[ins]
  1294. end
  1295. end
  1296. if lr == "setdb" then
  1297. if data7 == nil then
  1298. return "no data to edit"
  1299. else
  1300. data7[ins] = cc
  1301. return ("value changed too " .. type(cc))
  1302. end
  1303. end
  1304. if ins[2] == lr or ins[2] == "tout" then
  1305. if ins ~= nil then
  1306. local oldcol1 = term.getTextColor()
  1307. local oldcol2 = term.getBackgroundColor()
  1308. term.setBackgroundColor(colors[col2])
  1309. term.setTextColor(colors[col1])
  1310. if data7 == nil then
  1311. data7 = {}
  1312. for is = 0, 1000 do
  1313. data7[is] = false
  1314. end
  1315. end
  1316. if data8 == nil then
  1317. data8 = {}
  1318. for is = 0, 1000 do
  1319. data8[is] = false
  1320. end
  1321. end
  1322. if data8[cc] == false then
  1323. data8[cc] = start
  1324. term.setCursorPos(pos1 + 6, pos2)
  1325. term.write(data8[cc])
  1326. end
  1327. term.setCursorPos(pos1, pos2)
  1328. term.write("start")
  1329. if terminal.API(ins, pos1, pos2, 4, 1) == true then
  1330. data7[cc] = true
  1331. end
  1332. if data7[cc] == true then
  1333. if data8[cc] > 0 then
  1334. repeat
  1335. timeOut = data8[cc]
  1336. term.setBackgroundColor(colors[col3])
  1337. data8[cc] = data8[cc] - change
  1338. term.setCursorPos(pos1 + 6, pos2)
  1339. sleep(1)
  1340. term.write(data8[cc])
  1341. until data8[cc] == 0
  1342. return "ended"
  1343. end
  1344. end
  1345. if repeats == true then
  1346. data8[cc] = start
  1347. end
  1348. term.setBackgroundColor(colors[col2])
  1349. term.setCursorPos(pos1 + 6, pos2)
  1350. term.write(data8[cc])
  1351. term.setTextColor(oldcol1)
  1352. term.setBackgroundColor(oldcol2)
  1353. end
  1354. end
  1355. end
  1356.  
  1357. function terminal.bar(
  1358. pos1,
  1359. pos2,
  1360. length,
  1361. height,
  1362. ins,
  1363. max,
  1364. color1,
  1365. color2,
  1366. color3,
  1367. printval,
  1368. hor,
  1369. text,
  1370. format,
  1371. rect,
  1372. thicc)
  1373. if (ins == nil) or (ins < 0) then
  1374. ins = 0
  1375. end
  1376. if format == nil then
  1377. local format = false
  1378. end
  1379. if ins ~= nil then
  1380. oldcol = term.getBackgroundColor()
  1381. oldcol1 = term.getTextColor()
  1382. term.setTextColor(colors[color3])
  1383. local function reprint()
  1384. term.setBackgroundColor(colors[color1])
  1385. terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1386. term.setBackgroundColor(oldcol)
  1387. xm = term.getBackgroundColor()
  1388. xb = term.getTextColor()
  1389. term.setTextColor(xm)
  1390. term.setBackgroundColor(xb)
  1391. term.setCursorPos(pos1 - 1, pos2 - height)
  1392. if thicc then
  1393. term.setBackgroundColor(colors[color3])
  1394. end
  1395. if thicc then
  1396. term.write(string.rep("\x83", length + 1)) --\143
  1397. term.setTextColor(xb)
  1398. term.setBackgroundColor(xm)
  1399. else
  1400. term.write("\159" .. string.rep("\143", length - 1)) --\x83
  1401. term.setTextColor(xb)
  1402. term.setBackgroundColor(xm)
  1403. term.write("\144")
  1404. end
  1405. if thicc then
  1406. term.setBackgroundColor(colors[color3])
  1407. end
  1408. term.setCursorPos(pos1 - 1, pos2 + height)
  1409. if thicc then
  1410. term.write(string.rep("\x8c", length + 1)) --\131
  1411. else
  1412. term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  1413. end
  1414. for i = 0, (height * 2) - 2 do
  1415. if not thicc then
  1416. term.setTextColor(xm)
  1417. term.setBackgroundColor(xb)
  1418. end
  1419. term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  1420. if thicc then
  1421. term.setBackgroundColor(colors[color3])
  1422. end
  1423. term.write("\x95")
  1424. term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  1425. if not thicc then
  1426. term.setTextColor(xb)
  1427. term.setBackgroundColor(xm)
  1428. end
  1429. term.write("\x95")
  1430. end
  1431. end
  1432. if rect ~= false then
  1433. reprint()
  1434. else
  1435. terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1436. end
  1437. local drawLength = ins / max * length
  1438. local drawHeights = ins / max * height
  1439. local drawHeight = math.ceil(drawHeights)
  1440. local moveval = (drawHeight * 2) - 2
  1441. local z = pos2 + height
  1442. term.setBackgroundColor(colors[color2])
  1443. if (hor == false) or (hor == nil) then
  1444. terminal.fill(pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  1445. else
  1446. terminal.fill(pos1, (z - 1) - moveval, length - 1, moveval + 1)
  1447. end
  1448. if printval == true then
  1449. term.setCursorPos(pos1, pos2)
  1450. term.setTextColor(colors[color3])
  1451. if hor == true then
  1452. if format then
  1453. if ins >= max / 2 then
  1454. term.setBackgroundColor(colors[color2])
  1455. else
  1456. term.setBackgroundColor(colors[color1])
  1457. end
  1458. else
  1459. if ins >= (max / 2) - (max / height) then
  1460. term.setBackgroundColor(colors[color2])
  1461. else
  1462. term.setBackgroundColor(colors[color1])
  1463. end
  1464. end
  1465. elseif hor == false then
  1466. term.setCursorPos(pos1, pos2)
  1467. term.setTextColor(colors[color3])
  1468. if hor == true then
  1469. if ins >= 1 then
  1470. term.setBackgroundColor(colors[color2])
  1471. else
  1472. term.setBackgroundColor(colors[color1])
  1473. end
  1474. end
  1475. end
  1476. if format then
  1477. term.write(ins .. "/" .. max)
  1478. term.setCursorPos(pos1, pos2 + 1)
  1479. term.write(text)
  1480. else
  1481. term.write(ins .. "/" .. max .. " " .. text)
  1482. end
  1483. term.setBackgroundColor(oldcol)
  1484. term.setTextColor(oldcol1)
  1485. end
  1486. term.setTextColor(oldcol1)
  1487. term.setBackgroundColor(oldcol)
  1488. end
  1489. end
  1490.  
  1491. function terminal.frame(pos1, pos2, length, height, color3, color1, thicc)
  1492. local oldcol = term.getBackgroundColor()
  1493. local oldcol1 = term.getTextColor()
  1494. term.setBackgroundColor(colors[color1])
  1495. terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1496. term.setBackgroundColor(oldcol)
  1497. xm = term.getBackgroundColor()
  1498. xb = term.getTextColor()
  1499. term.setTextColor(xm)
  1500. term.setBackgroundColor(xb)
  1501. term.setCursorPos(pos1 - 1, pos2 - height)
  1502. if thicc then
  1503. term.setBackgroundColor(colors[color3])
  1504. term.setTextColor(oldcol)
  1505. term.write(string.rep("\x83", length + 1)) --\143
  1506. term.setTextColor(xb)
  1507. term.setBackgroundColor(xm)
  1508. else
  1509. term.setTextColor(oldcol)
  1510. term.setBackgroundColor(colors[color3])
  1511. term.write("\159" .. string.rep("\143", length - 1)) --\x83
  1512. term.setTextColor(colors[color3])
  1513. term.setBackgroundColor(oldcol)
  1514. term.write("\144")
  1515. end
  1516. term.setCursorPos(pos1 - 1, pos2 + height)
  1517. if thicc then
  1518. term.setBackgroundColor(oldcol)
  1519. term.setTextColor(colors[color3])
  1520. term.write(string.rep("\x8f", length + 1)) --\131
  1521. term.setBackgroundColor(colors[color1])
  1522. term.setTextColor(colors[color3])
  1523. else
  1524. term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  1525. end
  1526. for i = 0, (height * 2) - 2 do
  1527. if not thicc then
  1528. term.setTextColor(xm)
  1529. term.setBackgroundColor(xb)
  1530. end
  1531. term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  1532. if thicc then
  1533. term.setBackgroundColor(colors[color3])
  1534. end
  1535. term.setBackgroundColor(colors[color3])
  1536. term.write("\x95")
  1537. term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  1538. if not thicc then
  1539. term.setTextColor(xb)
  1540. term.setBackgroundColor(xm)
  1541. end
  1542. term.setTextColor(colors[color3])
  1543. term.write("\x95")
  1544. end
  1545. term.setBackgroundColor(oldcol)
  1546. term.setTextColor(oldcol1)
  1547. end
  1548.  
  1549. return {
  1550. monitor = monitor,
  1551. terminal = terminal
  1552. }
  1553.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement