Advertisement
hornedcommando

Minecraft ComputerCraft Modem Crafter Above and Beyond

Nov 22nd, 2024
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | Gaming | 0 0
  1. ---
  2. ---Desc: A program to send a craft command to a turtle connected to the system
  3. ---This shows this functionality in it's simplest form and will be added upon to make a turtle autocrafter
  4. ---Pairs with Listener.lua to make the turtle craft
  5. ---
  6.  
  7. --By: hornedcommando
  8.  
  9. -- Function to find the side with the modem
  10. local function findModemSide()
  11.     for _, side in ipairs(peripheral.getNames()) do
  12.         if peripheral.getType(side) == "modem" then
  13.             print("Found modem on side: " .. side)
  14.             return side
  15.         end
  16.     end
  17.     error("No modem found")
  18. end
  19.  
  20. -- Open the modem
  21. local modemSide = findModemSide()
  22. rednet.open(modemSide)
  23.  
  24. print("Enter the ID of the turtle:")
  25. local turtleId = tonumber(read())
  26.  
  27. -- Send the "craft" command to the specified turtle ID
  28. rednet.send(turtleId, "craft")
  29.  
  30. -- Wait for confirmation from the turtle
  31. local senderId, response = rednet.receive()
  32.  
  33. -- Print the response from the turtle
  34. print("Response from turtle:", response)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement