Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---Desc: A program to send a craft command to a turtle connected to the system
- ---This shows this functionality in it's simplest form and will be added upon to make a turtle autocrafter
- ---Pairs with Listener.lua to make the turtle craft
- ---
- --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)
- print("Enter the ID of the turtle:")
- local turtleId = tonumber(read())
- -- Send the "craft" command to the specified turtle ID
- rednet.send(turtleId, "craft")
- -- Wait for confirmation from the turtle
- local senderId, response = rednet.receive()
- -- Print the response from the turtle
- print("Response from turtle:", response)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement