Advertisement
jaklsfjlsak

摄像头监控简化

Mar 26th, 2025 (edited)
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local allowed = {"Ares_Xiao_Hu", "Destiney"}
  2.  
  3. -- Function to check if a player's name is in the whitelist.
  4. local function isWhitelisted(playerName)
  5.   for i = 1, #allowed do
  6.     if playerName == allowed[i] then
  7.       return true
  8.     end
  9.   end
  10.   return false
  11. end
  12.  
  13. local function tick()
  14.   local cameras = {}
  15.   local sides = peripheral.getNames()
  16.  
  17.   -- Find and wrap all warpdrive cameras.
  18.   for _, side in pairs(sides) do
  19.     if peripheral.getType(side) == "warpdriveCamera" then
  20.       print("Camera found on " .. side)
  21.       table.insert(cameras, peripheral.wrap(side))
  22.     end
  23.   end
  24.  
  25.   while true do
  26.     for _, camera in ipairs(cameras) do
  27.       local count = camera.getResultsCount()
  28.       if count and count > 0 then
  29.         for i = 0, count - 1 do
  30.           local success, entityType, playerName, x, y, z = camera.getResult(i)
  31.           if success and entityType == "minecraft:player" and not isWhitelisted(playerName) then
  32.             x = math.floor(x * 10) / 10
  33.             y = math.floor(y * 10) / 10
  34.             z = math.floor(z * 10) / 10
  35.             print(playerName .. " detected at (" .. x .. ", " .. y .. ", " .. z .. ")")
  36.           end
  37.         end
  38.       end
  39.       os.sleep(0.1)
  40.     end
  41.   end
  42. end
  43.  
  44. tick()
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement