Advertisement
Win4Win

OpenComputers Tablet testing

Sep 16th, 2023 (edited)
1,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. --- Form Field -------
  2. secondsToRepeat = 5
  3. -----------------------
  4. local whitelist = {
  5.     "Spectrolus"
  6.   }
  7.  
  8. for index, value in pairs(whitelist) do
  9.     whitelist[value] = "Mafia"
  10. end
  11.  
  12. local radar = require("component").radar
  13. local term = require("term")
  14. local computer = require("computer")
  15. local noise = require("component").noise
  16. term.clear()
  17. while true do
  18.    term.clear()
  19.    print(computer.energy())
  20.    freq = 0
  21.    found = 0
  22.    for i, v in ipairs(radar.getPlayers()) do
  23.      if whitelist[v.name] == nil then
  24.         if v.distance > freq then
  25.           freq = (500 - v.distance) + 50
  26.         end
  27.         print(v.name, v.distance)
  28.         found = 1
  29.      end
  30.      if found == 1 then
  31.        noise.setMode(1, noise.modes.triangle)
  32.        noise.play({{170, 0.3}})
  33.      end
  34.    end
  35.    os.sleep(secondsToRepeat)
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement