Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Beef's Porta-Matrix Pocket-Computer Script--
- --wrapping the ender modem behind the Pocket Comptuer--
- local m = peripheral.wrap("back")
- --listening on channel 241--
- m.open(241)
- --refresh monitor
- term.clear()
- --setting universal variables--
- monX, monY = term.getSize()
- local mult = 10^2
- local center = math.floor(monX/2)
- while (true)
- do
- --reading for message events--
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- --unserializing the table from message-- MASSIVE thanks to Fatboychummy on discord for helping me understand wireless events and tables.
- local mD = textutils.unserialise(message)
- --create power bar math
- local charge = math.floor(mD.curPow / mD.maxPow * 100 + 0.5)
- local tUse = math.floor((mD.curIn+mD.curOut)/mD.tfCap * 100 + 0.5)
- --set title--
- term.clear()
- term.setCursorPos(center-7,1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- print(" Porta-Matrix ")
- --draw labels--
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.orange)
- term.setCursorPos(center-5,3)
- print("Max Power:")
- term.setCursorPos(center-7,5)
- print("Current Power:")
- term.setCursorPos(center-3,7)
- print("Input:")
- term.setCursorPos(center-3,9)
- print("Output:")
- term.setCursorPos(center-6,11)
- print("Transfer Cap:")
- term.setCursorPos(2,14)
- print("Charge:")
- term.setCursorPos(2,17)
- print("Transfer Usage:")
- --format power level text--
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- --write max power--
- term.setTextColor(colors.white)
- term.setCursorPos(center-4, 4)
- e = mD.maxPow
- if e >= 1000 and e < 1000000 then
- term.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
- term.write("kRF")
- elseif e >= 1000000 and e < 1000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
- term.write("mRF")
- elseif e >= 1000000000 and e < 1000000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
- term.write("gRF")
- else
- term.write(tostring(mD.maxPow))
- term.write("RF")
- end
- --write current power--
- term.setTextColor(colors.white)
- term.setCursorPos(center-4, 6)
- e = mD.curPow
- if e >= 1000 and e < 1000000 then
- term.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
- term.write("kRF")
- elseif e >= 1000000 and e < 1000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
- term.write("mRF")
- elseif e >= 1000000000 and e < 1000000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
- term.write("gRF")
- else
- term.write(tostring(mD.curPow))
- term.write("RF")
- end
- --write input--
- term.setTextColor(colors.white)
- term.setCursorPos(center-5, 8)
- e = mD.curIn
- if e >= 1000 and e < 1000000 then
- term.setCursorPos(center-4, 8)
- term.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
- term.write("kRF/t")
- elseif e >= 1000000 and e < 1000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
- term.write("mRF/t")
- elseif e >= 1000000000 and e < 1000000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
- term.write("gRF/t")
- else
- term.setCursorPos(center-2, 8)
- term.write("0RF/t")
- end
- --write output--
- term.setTextColor(colors.white)
- term.setCursorPos(center-4, 10)
- e = mD.curOut
- if e >= 1000 and e < 1000000 then
- term.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
- term.write("kRF/t")
- elseif e >= 1000000 and e < 1000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
- term.write("mRF/t")
- elseif e >= 1000000000 and e < 1000000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
- term.write("gRF/t")
- else
- term.setCursorPos(center-2, 10)
- term.write("0RF/t")
- end
- --write transfer cap--
- term.setTextColor(colors.white)
- term.setCursorPos(center-5, 12)
- e = mD.tfCap
- if e >= 1000 and e < 1000000 then
- term.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
- term.write("kRF/t")
- elseif e >= 1000000 and e < 1000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
- term.write("mRF/t")
- elseif e >= 1000000000 and e < 1000000000000 then
- term.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
- term.write("gRF/t")
- else
- term.write(tostring(mD.tfCap))
- term.write("RF/t")
- end
- --write graph percentages--
- term.setCursorPos(10,14)
- print(charge.."%")
- term.setCursorPos(18,17)
- print(tUse.."%")
- --calculate graph fill--
- powBar = math.floor((mD.curPow/mD.maxPow)*(monX-2)+0.5)
- tBar = math.floor(((mD.curIn+mD.curOut)/mD.tfCap)*(monX-2)+0.5)
- --draw power bar--
- term.setBackgroundColor(colors.purple)
- term.setCursorPos(2,15)
- term.write(string.rep(" ",(monX-2)))
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(2,15)
- term.write(string.rep(" ",powBar))
- --draw transfer bar--
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(2,18)
- term.write(string.rep(" ",(monX-2)))
- term.setBackgroundColor(colors.red)
- term.setCursorPos(2,18)
- term.write(string.rep(" ",tBar))
- --reformat background--
- term.setBackgroundColor(colors.black)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement