Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Graphical Speedtest Version 0.1
- --IMPORTANT FUNCTION
- function centerText(text) --SOURCE: http://www.computercraft.info/forums2/index.php?/topic/460-how-to-center-text/
- local x,y = term.getSize()
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- --@TXT!ID123
- centerText("Hello World")
- function string_speed(re)
- ss = os.clock()
- w = fs.open("SpeedFile","r")
- rednet.send(tonumber(re),w.readAll(),true)
- sa = os.clock()
- event, id, text = os.pullEvent()
- if event == "rednet_message" then
- return "Speed: " .. math.abs(1024 / sa - ss) .." KiloByes/Sec."
- end
- w.close()
- end
- function string_latency(rer)
- fb = os.clock()
- rednet.send(tonumber(rer),"1111111111111111111111111111111",true)
- events, ids, texts = os.pullEvent()
- if events == "rednet_message" then
- fn = os.clock()
- return "Latency: " .. fn - fb .. "s"
- end
- end
- function crap()
- rednet.open("back")
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.blue)
- term.write("RedTest Graphical Version ")
- --term.setCursorPos(x>,y^)
- term.setCursorPos(1,4)
- term.write(" ")
- term.setCursorPos(1,5)
- term.write(" ")
- centerText("Latency")
- term.setCursorPos(1,6)
- term.write(" ")
- term.setTextColor(colors.purple)
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(1,8)
- term.write(" ")
- term.setCursorPos(1,9)
- term.write(" ")
- centerText("Bit Rate")
- term.setCursorPos(1,10)
- term.write(" ")
- term.setCursorPos(1,12)
- term.setTextColor(colors.lime)
- term.setBackgroundColor(colors.purple)
- term.write(" ")term.setCursorPos(1,13)
- term.write(" ")
- centerText("Both")
- term.setCursorPos(1,14)
- term.write(" ")
- term.setBackgroundColor(colors.black)
- while true do
- sleep(0)
- event, button, x, y =os.pullEvent("mouse_click")
- if y == 5 or y==6 or y==4 then
- term.setCursorPos(1,4)
- centerText("COMPUTER ID: ")
- term.setCursorPos(1,5)
- js = read()
- term.setCursorPos(1,6)
- centerText(string_latency(js))
- sleep(4)
- crap()
- elseif y == 9 or y==8 or y==10 then
- term.setCursorPos(1,8)
- centerText("COMPUTER ID: ")
- term.setCursorPos(1,9)
- jss = read()
- term.setCursorPos(1,10)
- centerText(string_speed(jss))
- sleep(4)
- crap()
- elseif y == 13 or y==12 or y==14 then
- term.setCursorPos(1,12)
- centerText("COMPUTER ID: ")
- term.setCursorPos(1,13)
- jsss = read()
- term.setCursorPos(1,14)
- centerText(string_latency(jsss) .. " " .. string_speed(jss))
- sleep(4)
- crap()
- else
- end
- end
- end
- crap()
Advertisement
Add Comment
Please, Sign In to add comment