Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local COMPUTER_ID = 21 -- ID Of Computer That Acts as a Logic Controller for the Turtle
- local WIRELESS_MODEM_SIZE = "left" -- Side that has Wireless Modem Equipped
- local ANTENNA_SIDE = "right" -- Side of Turtle that has the duck antenna from openperipheraladdons equipped
- rednet.open(WIRELESS_MODEM_SIZE) -- Opens Rednet Communications with Equipped Modem
- local Inventory = peripheral.wrap(ANTENNA_SIDE) -- Wraps Turtle's Inventory for Easy Access
- local InvSize = Inventory.getInventorySize() -- Stores Turtle's Inventory Size
- local CommandList = {} -- Table that will hold the funcations for each command that is send across Rednet
- --Starts the Ritual Crafting by inserting Target Item
- function craftItem(name)
- for i=1,InvSize,1 do
- local tmp = Inventory.getStackInSlot(i)
- if(tmp ~= nil) then
- if(tmp.display_name == name) then
- turtle.select(i)
- return turtle.drop()
- end
- end
- end
- return false
- end
- --Stops the Ritual from Crafting by removing target item
- function stopCraft()
- return turtle.suck()
- end
- CommandList["craft"] = craftItem(x) -- Adds CraftItem to command list with parameter
- CommandList["stop"] = stopCraft() -- Adds StopCraft to command list
- --Main Control Loop
- while(true) do
- local event, id, msg = os.pullEvent("rednet_message") --Waits for Rednet Message From Logic Computer
- local cmd = textutils.unserialize(msg) --Unserializes Command Table from Rednet Message
- if(cmd[1] == "craft") then --Runs Command and passes parameter with it
- print("Crafting ", cmd[2])
- craftItem(cmd[2])
- elseif (cmd[1] == "stop") then
- print("Craft Finished")
- stopCraft()
- end
- sleep(1) --Sleeps for a second
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement