Advertisement
Qut10w

Untitled

May 16th, 2024
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | Source Code | 0 0
  1. local modem = peripheral.find("modem")
  2. local sleepTime = 0.5
  3. modem.open(1)
  4.  
  5. local function handleCraftingCommand()
  6.     while true do
  7.         local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  8.         if message and type(message) == "table" and message.item and message.quantity then
  9.             local status = "error"
  10.             if turtle.craft(math.min(message.quantity, 64)) then
  11.                 print("Craft ".. message.item .. " succeeds!")
  12.                 status = "ok"
  13.             else
  14.                 print("Craft ".. message.item .. " error!")
  15.             end
  16.  
  17.             local message = {status = status}
  18.             modem.transmit(1, 1, message)
  19.         end
  20.     end
  21. end
  22.  
  23. handleCraftingCommand()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement