Advertisement
osmarks

ID Waster

Jan 6th, 2020
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local m = peripheral.find "modem"
  2.  
  3. local function log(base, n)
  4.     return math.log(n) / math.log(base)
  5. end
  6.  
  7. local function ID_is_cool(ID)
  8.     for i = 2, 20 do
  9.         local x = log(i, ID)
  10.         if math.floor(x) == x then return true end
  11.     end
  12.     return false
  13. end
  14.  
  15. if turtle then
  16.     m.open(0)
  17.  
  18.     while true do
  19.         turtle.dig()
  20.         turtle.place()
  21.         peripheral.call("front", "turnOn")
  22.         local _, _, _, _, message = os.pullEvent "modem_message"
  23.         print(message)
  24.         if ID_is_cool(message) then
  25.             os.shutdown()
  26.         end
  27.         sleep(2)
  28.     end
  29. else
  30.     local f = fs.open("test", "w")
  31.     f.write "Hi"
  32.     f.close()
  33.     fs.delete "test"
  34.     m.transmit(0, 0, os.getComputerID())
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement