Dimencia

Clock2

Jul 21st, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1.  
  2.  
  3. rednet.open("front")
  4. targetid = 3 -- You still gotta set this if you move.
  5.  
  6. local lastTime = os.epoch('utc')
  7. local lastClock = os.clock()
  8.  
  9. while true do
  10.  os.sleep(0.5)
  11.  local time = os.epoch('utc') - lastTime   -- real world milliseconds
  12.  local clock = os.clock() - lastClock   -- ticks * 0.05
  13.  lastTime = time
  14.  lastClock = clock
  15.  local tps = (clock * 20) / (time / 1000)
  16.  
  17.  print(tps)
  18.  
  19.  local ratio = tps/20
  20.  print(ratio)
  21.  rednet.send(targetid,"speed "..ratio)
  22.  
  23. end
Advertisement
Add Comment
Please, Sign In to add comment