Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---Desc: A Program for a turtle which makes it listen for a "craft" message and causes
- ---it to run turtle.craft() when it gets the message
- ---pairs with Modem Crafter, pastebin: gx4XjreV
- ---
- --By: hornedcommando
- -- Function to find the side with the modem
- local function findModemSide()
- for _, side in ipairs(peripheral.getNames()) do
- if peripheral.getType(side) == "modem" then
- print("Found modem on side: " .. side)
- return side
- end
- end
- error("No modem found")
- end
- -- Open the modem
- local modemSide = findModemSide()
- rednet.open(modemSide)
- while true do
- -- Receive command from the computer
- local senderId, message = rednet.receive()
- -- If the received message is "craft", execute turtle.craft()
- if message == "craft" then
- turtle.craft()
- -- Send confirmation back to the sender
- rednet.send(senderId, "Crafting complete!")
- else
- -- Send a message back if the command is not recognized
- rednet.send(senderId, "Unknown command")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement