Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local idMax = 20 --#Change this to the maximum ID number you're using.
- local idMin = 1 --#Change this to the minimum ID number you're using.
- local modemSide = "top" --#Change this if you change where the modem is.
- local myID = os.getComputerID()
- local modem = peripheral.wrap(modemSide)
- modem.open(myID)
- local function getID()
- while true do
- local idNum = math.random(idMin,idMax)
- if idNum ~= myID then
- return idNum
- end
- end
- end
- local function main()
- while true do
- local event = {os.pullEvent()}
- if event[1] == "modem_message" then
- print("\nVillager ".. event[4] .." sent you a message: "..event[5])
- end
- end
- end
- local function send()
- local input = read()
- modem.transmit(getID(),myID,input)
- end
- while true do
- parallel.waitForAny(main,send)
- end
Advertisement
Add Comment
Please, Sign In to add comment