Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local responseTable = {"Hello.","How are you?",
- "What is your name?","Do you want to hang out?","Yes.","No.",
- "Where do you live?", "In a house."} --[[#If you want more responses for
- the villagers to say then just add a comma , and put the text in quotes,
- then do so for each response]]--
- local lampTime = 5 --#Change for the time the lamp will stay on.
- 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 plate = "left" --#If you move the plate, change this to the side
- local lamp = "right" --#Same for the lamp.
- local modemSide = "top" --#Same for the modem
- local myID = os.getComputerID()
- local modem = peripheral.wrap(modemSide)
- modem.open(myID)
- local tID = os.startTimer(1)
- local function response()
- return responseTable[math.random(1,#responseTable)]
- end
- local function getID()
- while true do
- local idNum = math.random(idMin,idMax)
- if idNum ~= myID then
- return idNum
- end
- end
- end
- while true do
- local event = {os.pullEvent()}
- if event[1] == "modem_message" then
- print("Villager ".. event[4] .." sent you a message: "..event[5])
- rs.setOutput(lamp,true)
- tID = os.startTimer(lampTime)
- elseif event[1] == "redstone" then
- if rs.getInput(plate) then
- modem.transmit(getID(),myID,response())
- end
- elseif event[1] == "timer" and event[2] == tID then
- rs.setOutput(lamp,false)
- sleep(0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment