Advertisement
Sparkybearbomb

Create Vault Display Server

Dec 3rd, 2024 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Set the vault and monitor peripherals
  2. function monitorSearch()
  3.    local names = peripheral.getNames()
  4.    local i, name
  5.    for i, name in pairs(names) do
  6.       if peripheral.getType(name) == "monitor" then
  7.          return peripheral.wrap(name)
  8.       else
  9.          --return null
  10.       end
  11.    end
  12. end
  13.  
  14. function modemSearch()
  15.    local names = peripheral.getNames()
  16.    local i, name
  17.    for i, name in pairs(names) do
  18.       if peripheral.getType(name) == "modem" then
  19.          return peripheral.wrap(name)
  20.       else
  21.          --return null
  22.       end
  23.    end
  24. end
  25.  
  26. monitor = monitorSearch()
  27. modem = modemSearch()
  28.  
  29. modem.open(1)
  30. modem.open(2)
  31.  
  32. while true do
  33.    local event, side, channel, replyChannel, message, distance
  34.    event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  35.    if((channel == 1) and (message == "Hello")) then
  36.       modem.transmit(replyChannel, 1, "Confirmed")
  37.    elseif(channel == 2) then
  38.       charPos = string.find(message,":")
  39.       qty = string.sub(message,(charPos+1))
  40.       name = string.sub(message,0,(charPos-1))
  41.       print(name.." "..qty)
  42.       modem.transmit(replyChannel, 2, "Okay")
  43.    end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement