Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- local data = {}
- local x, y, z
- p = peripheral.wrap("right")
- function waitDone()
- while not p.isActionDone() do
- sleep(1)
- end
- end
- function isDone(data, id)
- if p.getAction() then
- rednet.send(id, p.isActionDone())
- else
- print("No action")
- rednet.send(id, true)
- end
- end
- function sendAction(data, id)
- rednet.send(id, p.getAction())
- end
- function hasItem(data, id)
- if data[1] ~= "" then
- p.clearWhitelistItemFilter()
- p.addWhitelistItemFilter(data[1], 0, false, false, false, false)
- end
- p.setAction("droneConditionItem")
- rednet.send(id, p.evaluateCondition())
- p.clearWhitelistItemFilter()
- end
- function getPressure(data, id)
- rednet.send(id, p.getDronePressure())
- end
- function getPosition(data, id)
- local tempdata = {}
- tempdata[1], tempdata[2], tempdata[3] = p.getDronePosition()
- rednet.send(id, textutils.serialize(tempdata))
- end
- function goto(data)
- p.clearArea()
- p.addArea(data[1], data[2], data[3])
- p.setAction("goto")
- end
- function teleport(data)
- p.clearArea()
- p.addArea(data[1], data[2], data[3])
- p.setAction("teleport")
- end
- function setSpot(data)
- p.addArea(data[1], data[2], data[3])
- end
- function setArea(data)
- p.addArea(data[1], data[2], data[3], data[4], data[5], data[6], data[7])
- end
- function showArea()
- if data[1] then
- p.showArea()
- else
- p.hideArea()
- end
- end
- function clearArea()
- p.clearArea()
- end
- function abortAction()
- p.abortAction()
- end
- function dig()
- p.clearWhitelistItemFilter()
- p.setAction("dig")
- end
- function entityImport()
- p.clearWhitelistText()
- p.setAction("entityImport")
- end
- function entityExport()
- p.clearWhitelistText()
- p.setAction("entityExport")
- end
- function place()
- p.clearWhitelistItemFilter()
- p.setAction("place")
- end
- function attack()
- p.forgetTarget()
- p.setAction("entityAttack")
- end
- function pickup()
- p.clearWhitelistItemFilter()
- p.setAction("pickupItem")
- end
- function inventoryImport(data)
- if data[1] ~= "" then
- p.clearWhitelistItemFilter()
- p.addWhitelistItemFilter(data[1], 0, false, false, false, false)
- else
- p.clearWhitelistItemFilter()
- end
- p.setSides(true, true, true, true, true, true)
- p.setAction("inventoryImport")
- --p.clearWhitelistItemFilter()
- --p.setSides(false, false, false, false, false, false)
- end
- function inventoryExport(data)
- if data[1] ~= "" then
- p.clearWhitelistItemFilter()
- p.addWhitelistItemFilter(data[1], 0, false, false, false, false)
- else
- p.clearWhitelistItemFilter()
- end
- p.setSides(true, true, true, true, true, true)
- p.setAction("inventoryExport")
- --p.clearWhitelistItemFilter()
- --p.setSides(false, false, false, false, false, false)
- end
- function msg()
- data = {}
- id, message, distance, protocol = rednet.receive()
- print(message)
- data = textutils.unserialize(message)
- if data[0] == "goto" then
- goto(data)
- elseif data[0] == "teleport" then
- teleport(data)
- elseif data[0] == "setSpot" then
- setSpot(data)
- elseif data[0] == "setArea" then
- setArea(data)
- elseif data[0] == "dig" then
- dig()
- elseif data[0] == "pickup" then
- pickup()
- elseif data[0] == "clearArea" then
- clearArea()
- elseif data[0] == "showArea" then
- showArea(data)
- elseif data[0] == "inventoryImport" then
- inventoryImport(data)
- elseif data[0] == "inventoryExport" then
- inventoryExport(data)
- elseif data[0] == "isDone" then
- isDone(data, id)
- elseif data[0] == "getAction" then
- sendAction(data, id)
- elseif data[0] == "getPressure" then
- getPressure(data, id)
- elseif data[0] == "getPosition" then
- getPosition(data, id)
- elseif data[0] == "hasItem" then
- hasItem(data, id)
- elseif data[0] == "attack" then
- attack()
- elseif data[0] == "place" then
- place()
- elseif data[0] == "entityImport" then
- entityImport()
- elseif data[0] == "entityExport" then
- entityExport()
- elseif data[0] == "exitPiece" then
- abortAction()
- end
- end
- while true do
- msg()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement