Advertisement
Guest User

reciever

a guest
Apr 5th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1. destTape1 = peripheral.wrap("right")
  2. destTape2 = peripheral.wrap("left")
  3. modem = peripheral.wrap("top")
  4.  
  5. modem.open(1337)
  6.  
  7. function ModemRecieve()
  8.     local tempA, tempB, tempC, tempD, chonker = os.pullEvent("modem_message")
  9.     print("chonker recieved")
  10.     return chonker
  11. end
  12.  
  13. while true do
  14.     time = os.time()
  15.     if time%0.1 == 0 then
  16.         os.sleep(2.75)
  17.         print("time satisfied")
  18.         break
  19.     end
  20.     os.queueEvent("randomEvent")
  21.     os.pullEvent()
  22. end
  23.  
  24. function main()
  25.     singleUse = true
  26.     print("main running")
  27.     while true do
  28.         --
  29.         --setting timers
  30.         --
  31.         print("setting timers")
  32.         -- immediate -- U/M 1, M 2
  33.         first = os.startTimer(0.4) -- Stop 2, WRIT
  34.         second = os.startTimer(1) -- Start 2
  35.         third = os.startTimer(2.5) -- U/M 2, M 1
  36.         fourth = os.startTimer(2.9) -- Stop 1, WRIT
  37.         fifth = os.startTimer(3.5) -- Start 1
  38.         sixth = os.startTimer(5) -- Loop
  39.         --
  40.         -- First Stage
  41.         --
  42.         -- 0 seconds in
  43.         --
  44.         print("unmuting Tape 1, muting Tape 2")
  45.         destTape1.setVolume(1)
  46.         os.sleep(0.1)
  47.         destTape2.setVolume(0)
  48.         os.sleep(0.25)
  49.         --
  50.         -- Second Stage
  51.         --
  52.         -- 0.75 seconds in
  53.         --
  54.         local temp, ID1 = os.pullEvent("timer")
  55.         print(ID1)
  56.         print("stopping Tape 2, writing")
  57.         local chonker = ModemRecieve()
  58.         destTape2.stop()
  59.         destTape2.seek((-destTape2.getPosition())+2000)
  60.         for i=1,60 do
  61.             destTape2.write(chonker[i])
  62.         end
  63.         destTape2.seek((-destTape2.getPosition()))
  64.         --
  65.         -- Third Stage
  66.         --
  67.         -- 1.1 second in
  68.         --
  69.         local temp, ID2 = os.pullEvent("timer")
  70.         destTape2.play()
  71.         print(ID2)
  72.         if ID1 + 1 ~= ID2 then
  73.             break
  74.         end
  75.         print("playing Tape 2")
  76.         --
  77.         -- Fourth Stage
  78.         --
  79.         -- 2.5 seconds in
  80.         --
  81.         local temp, ID = os.pullEvent("timer")
  82.         print("unmuting Tape 2, muting Tape 1")
  83.         destTape2.setVolume(1)
  84.         os.sleep(0.1)
  85.         destTape1.setVolume(0)
  86.         os.sleep(0.25)
  87.         --
  88.         -- Fifth Stage
  89.         --
  90.         -- 3.25 seconds in
  91.         --
  92.         local temp, ID = os.pullEvent("timer")
  93.         print("stopping Tape 1, writing")
  94.         local chonker = ModemRecieve()
  95.         destTape1.stop()
  96.         destTape1.seek((-destTape1.getPosition())+2000)
  97.         for i=1,60 do
  98.             destTape1.write(chonker[i])
  99.         end
  100.         destTape1.seek((-destTape1.getPosition()))
  101.         --
  102.         -- Sixth Stage
  103.         --
  104.         -- 3.6 seconds in
  105.         --
  106.         local temp, ID = os.pullEvent("timer")
  107.         print("playing Tape 1")
  108.         destTape1.play()
  109.         --
  110.         -- Seventh Stage
  111.         --
  112.         -- 5 seconds in
  113.         --
  114.         local temp, ID = os.pullEvent("timer")
  115.         print("looping")
  116.     end
  117. end
  118.  
  119. os.pullEvent("modem_message")
  120. os.sleep(1.4)
  121.  
  122. while true do
  123.     main()
  124.     os.sleep(0.5)
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement