osmarks

Thing 3

Mar 6th, 2022 (edited)
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sensor = peripheral.find "plethora:sensor"
  2. local modem = peripheral.find "modem"
  3. local channel = 49961
  4. local offset = vector.new(-3, -3, 2)
  5.  
  6. local function randbytes(len)
  7.     local out = ""
  8.     for i = 1, len do
  9.         out = out .. string.char(math.random(0, 255))
  10.     end
  11.     return out
  12. end
  13.  
  14. local function main()
  15.     while true do
  16.         local entities = sensor.sense()
  17.         local open = false
  18.         for _, entity in pairs(entities) do
  19.             local position = vector.new(entity.x, entity.y, entity.z) + offset
  20.             if entity.displayName == "6_4" or entity.displayName == "gollark" and position:length() < 4 then
  21.                 open = true
  22.             end
  23.         end
  24.         math.randomseed(math.floor(os.clock() * 100))
  25.         local rc = math.random(0, 65535)
  26.         modem.transmit(channel, rc, open)
  27.         print(open, rc)
  28.         sleep(0.1)
  29.     end
  30. end
  31.  
  32. main()
Add Comment
Please, Sign In to add comment