9551

Untitled

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