Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function proxyFor(name, required)
- local address = component and component.list(name)()
- if not address and required then
- error("missing component '" .. name .. "'")
- end
- return address and component.proxy(address) or nil
- end
- local component = require "component"
- local robot = component.robot
- local grabber = component.inventory_controller
- local network = require("internet")
- local os = require "os"
- local robotAPI = require "robot"
- local function moveCoord(x,y,z)
- -- X (go forwards)
- for i=1,x,1 do
- robot.move(3)
- end
- -- Z (go left)
- robot.turn(false)
- for i=0,z,1 do
- robot.move(3)
- end
- robot.turn(true)
- -- Y (go down)
- for i=1,y,1 do
- robot.move(0)
- end
- end
- -- Return
- local function returnCoord(x,y,z)
- -- Y (go up)
- for i=1,y,1 do
- robot.move(1)
- end
- -- Z (go right)
- robot.turn(true)
- for i=0,z,1 do
- robot.move(3)
- end
- robot.turn(false)
- -- X (go back)
- robot.turn(true)
- robot.turn(true)
- for i=1,x,1 do
- robot.move(3)
- end
- robot.turn(false)
- robot.turn(false)
- end
- -- Go to Name
- local function moveName(word)
- local tempArray = foodcords[word]
- local workedx = tempArray[1]
- local workedy = tempArray[2]
- local workedz = tempArray[3]
- workedx = workedx - -243
- workedy = workedy - 49
- workedz = workedz - 184
- workedy = workedy * -1
- workedz = workedz * -1
- moveCoord(workedx, workedy, workedz)
- end
- -- Return Back Name
- local function returnName(word)
- local tempArray = foodcords[word]
- local workedx = tempArray[1]
- local workedy = tempArray[2]
- local workedz = tempArray[3]
- workedx = workedx - -243
- workedy = workedy - 49
- workedz = workedz - 184
- workedy = workedy * -1
- workedz = workedz * -1
- returnCoord(workedx, workedy, workedz)
- end
- -- Take Amount
- local function transferAmount(amount)
- slots = math.ceil(amount/64)
- robot.turn(true)
- robot.turn(true)
- --Pull the stuff
- for i=1,slots,1 do
- if amount >= 64 then
- taking = 64
- else
- taking = amount
- end
- robot.select(i)
- grabber.suckFromSlot(3,1, taking)
- amount = amount - taking
- end
- robot.turn(false)
- robot.turn(false)
- end
- local function dumpInv(faction)
- robot.turn(false)
- if faction == "megacorp" then
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "shadow" then
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "domebois" then
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "lee" then
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- for i=1,32,1 do
- robot.select(i)
- grabber.dropIntoSlot(3, i)
- end
- if faction == "megacorp" then
- robot.turn(false)
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "domebois" then
- robot.turn(false)
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "shadow" then
- robot.turn(false)
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- if faction == "lee" then
- robot.turn(false)
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robotAPI.forward()
- robot.turn(false)
- end
- end
- local function internetRequest()
- -- Local Variables
- local stringSend = "http://86.7.146.45:4920/lastRequest"
- local a = network.request(stringSend)
- for request in a do
- if string.len(request) < 5 then
- return false, false, false
- else
- local requestArray = {}
- count = 0
- for i in string.gmatch(request, '([^,]+)') do
- if count == 2 or count == 3 then
- requestArray[count] = i:match("%d+")
- end
- if count == 1 or count == 0 then
- requestArray[count] = i
- end
- count = count + 1
- end
- local faction = requestArray[0]
- local item = requestArray[1]
- local amount = requestArray[3]
- faction = string.match(faction, "%a+")
- item = string.match(item, "%a+")
- amount = tonumber(amount)
- print(faction)
- print(item)
- print(amount)
- return faction, item, amount
- end
- end
- end
- local function delRequest()
- local delete = network.request("http://86.7.146.45:4920/deleteRequest")
- end
- foodcords = {}
- foodcords["potato"] = {-229, 48, 174}
- foodcords["blackberry"] = {-209, 48, 164}
- foodcords["cantaloupe"] = {-189, 48, 164}
- foodcords["ginger"] = {-179, 48, 154}
- foodcords["blueberry"] = {-199, 48, 164}
- foodcords["garlic"] = {-189, 48, 144}
- foodcords["corn"] = {-209, 48, 134}
- foodcords["eggplant"] = {-189, 48, 134}
- foodcords["cranberry"] = {-189, 48, 154}
- foodcords["kiwi"] = {-179, 48, 164}
- foodcords["broccoli"] = {-219, 48, 154}
- foodcords["bean"] = {-239, 48, 174}
- foodcords["bambooshoot"] = {-239, 48, 154}
- foodcords["beet"] = {-229, 48, 154}
- foodcords["brusselsprout"] = {-229, 48, 164}
- foodcords["cauliflower"] = {-209, 48, 154}
- foodcords["cotton"] = {-199, 48, 134}
- foodcords["grape"] = {-179, 48, 144}
- foodcords["leek"] = {-219, 48, 154}
- foodcords["lettuce"] = {-219, 48, 154}
- foodcords["mustards"] = {-219, 48, 154}
- foodcords["candleberry"] = {-219, 48, 154}
- foodcords["coffee"] = {-219, 48, 134}
- foodcords["oats"] = {-219, 48, 154}
- foodcords["okra"] = {-219, 48, 154}
- foodcords["onion"] = {-219, 48, 154}
- foodcords["parsnip"] = {-219, 48, 154}
- foodcords["peanut"] = {-219, 48, 154}
- foodcords["peas"] = {-219, 48, 154}
- foodcords["pineapple"] = {-219, 48, 154}
- foodcords["radish"] = {-219, 48, 154}
- foodcords["raspberry"] = {-219, 48, 154}
- foodcords["rhubarb"] = {-219, 48, 154}
- foodcords["rice"] = {-219, 48, 154}
- foodcords["rutabaga"] = {-219, 48, 154}
- foodcords["rye"] = {-219, 48, 154}
- foodcords["scallion"] = {-219, 48, 154}
- foodcords["seaweed"] = {-219, 48, 154}
- foodcords["sesames"] = {-219, 48, 154}
- foodcords["soybean"] = {-219, 48, 154}
- foodcords["spiceleaf"] = {-219, 48, 154}
- foodcords["spinach"] = {-219, 48, 154}
- foodcords["strawberry"] = {-219, 48, 154}
- foodcords["sweetpotato"] = {-219, 48, 154}
- foodcords["tea"] = {-219, 48, 154}
- foodcords["tomato"] = {-219, 48, 154}
- foodcords["turnip"] = {-219, 48, 154}
- foodcords["waterchestnut"] = {-219, 48, 154}
- foodcords["whushroom"] = {-219, 48, 154}
- foodcords["wintersquash"] = {-219, 48, 154}
- foodcords["zucchini"] = {-219, 48, 154}
- foodcords["cabbage"] = {-219, 48, 154}
- foodcords["cactusfruit"] = {-219, 48, 144}
- foodcords["chilipepper"] = {-229, 48, 134}
- foodcords["artichoke"] = {-239, 48, 134}
- foodcords["barley"] = {-239, 48, 164}
- foodcords["asparagus"] = {-239, 48, 145}
- foodcords["bellpepper"] = {-229, 48, 144}
- foodcords["celery"] = {-209, 48, 144}
- foodcords["cucumber"] = {-199, 48, 144}
- foodcords["curryleaf"] = {-199, 48, 154}
- while true do
- local faction, item, amount = internetRequest()
- print("after internet")
- if faction ~= false then
- print("good")
- moveName(item)
- transferAmount(amount )
- returnName(item)
- dumpInv(faction)
- delRequest()
- else
- print("bad")
- end
- os.sleep(2)
- os.sleep(2)
- end
Add Comment
Please, Sign In to add comment