Advertisement
appleguy1999

Untitled

Nov 30th, 2022 (edited)
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. running = false
  2. startTime = os.clock()
  3. endTime = os.clock()
  4. monitor = peripheral.wrap("left")
  5. monitor.setTextScale(4)
  6.  
  7. function round(num, numDecimalPlaces)
  8.   local mult = 10^(numDecimalPlaces or 0)
  9.   return math.floor(num * mult + 0.5) / mult
  10. end
  11.  
  12. while true do
  13.   os.pullEvent("redstone")
  14.   if rs.getInput("bottom") then
  15.     running = true
  16.     startTime = os.clock()
  17.     print("Start: " .. startTime)
  18.     monitor.setCursorPos(1,2)
  19.     monitor.write(" ...")
  20.   elseif rs.getInput("back") and running then
  21.     running = false
  22.     endTime = os.clock()
  23.     print("End: " .. endTime)
  24.     delta = round(endTime - startTime, 2)
  25.     monitor.setCursorPos(1,2)
  26.     monitor.write("    ")
  27.     monitor.setCursorPos(1,2)
  28.     monitor.write(delta)
  29.     print(delta)
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement