Advertisement
Alexr360

Miner Control

Mar 24th, 2024 (edited)
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local function clearScreen()
  2.   term.clear()
  3.   term.setCursorPos(1, 1)
  4. end
  5.  
  6. -- Set the side of the computer where the redstone signal will be emitted (change 'back' if needed)
  7. local side = "back"
  8.  
  9. redstone.setOutput(side, true)
  10.  
  11. -- Prompt the player to press enter to start
  12. print("Press Enter to start emitting the redstone signal.")
  13. while true do
  14.   local event, key = os.pullEvent("key")
  15.   if event == "key" and key == keys.enter then
  16.     break
  17.   end
  18. end
  19.  
  20. clearScreen()
  21.  
  22. -- Activate the redstone output
  23. redstone.setOutput(side, false)
  24. print("Redstone signal activated.")
  25.  
  26. local modem = peripheral.find("modem") or error("No modem attached", 0)
  27. modem.open(92) -- Open 43 so we can receive replies
  28.  
  29. -- And wait for a reply
  30. local event, side, channel, replyChannel, message, distance
  31. repeat
  32.     event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  33. until channel == 92
  34.  
  35. -- Deactivate the redstone output after the duration
  36. redstone.setOutput(side, true)
  37. print("Redstone signal deactivated.")
  38. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement