Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local robot = component.robot
- local inet = require("internet")
- local computer = require("computer")
- local grabber = component.inventory_controller
- local os = require("os")
- 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)
- if faction == "megacorp" then
- robot.turn(true)
- robot.turn(true)
- end
- if faction == "domebois" then
- robot.turn(true)
- end
- for i=1,32,1 do
- robot.select(i)
- grabber.dropIntoSlot(3, i)
- end
- if faction == "megacorp" then
- robot.turn(false)
- robot.turn(false)
- end
- if faction == "domebois" then
- robot.turn(false)
- end
- end
- local function internetRequest()
- local response = inet.request("https://stark-stream-56750.herokuapp.com/lastRequest")
- local body = ""
- for chunk in response do
- body = body .. chunk
- end
- if body == "[]" then
- return false, false, false, false
- end
- local requestArray = {}
- local count = 0
- for word in string.gmatch(body, '([^,]+)') do
- requestArray[count] = word
- count = count + 1
- end
- local index = requestArray[0]:match("%d+")
- local faction = requestArray[1]:match("%a+")
- local item = requestArray[2]:match("%a+")
- local amount = requestArray[3]:match("%d+")
- return index, faction, item, amount
- end
- local function deleteRequest()
- local delete = inet.request("https://stark-stream-56750.herokuapp.com/deleteRequest")
- end
- -- Make foods array
- foodcords = {}
- foodcords["potato"] = {-229, 48, 173}
- foodcords["blackberry"] = {-209, 48, 163}
- foodcords["cantaloupe"] = {-189, 48, 163}
- foodcords["ginger"] = {-179, 48, 153}
- foodcords["blueberry"] = {-199, 48, 163}
- foodcords["garlic"] = {-189, 48, 143}
- foodcords["corn"] = {-209, 48, 133}
- foodcords["eggplant"] = {-189, 48, 133}
- foodcords["cranberry"] = {-189, 48, 153}
- foodcords["kiwi"] = {-179, 48, 163}
- foodcords["broccoli"] = {-219, 48, 153}
- foodcords["bean"] = {-239, 48, 173}
- foodcords["potato"] = {-219, 48, 154}
- foodcords["bambooshoot"] = {-239, 48, 153}
- foodcords["beet"] = {-229, 48, 153}
- foodcords["brusselsprout"] = {-229, 48, 163}
- foodcords["cauliflower"] = {-209, 48, 153}
- foodcords["cotton"] = {-199, 48, 133}
- foodcords["grape"] = {-179, 48, 143}
- foodcords["leek"] = {-219, 48, 154}
- foodcords["lettuce"] = {-219, 48, 154}
- foodcords["mustards"] = {-219, 48, 154}
- foodcords["candleberry"] = {-219, 48, 154}
- foodcords["coffee"] = {-219, 48, 133}
- 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, 143}
- foodcords["chilipepper"] = {-229, 48, 133}
- foodcords["artichoke"] = {-239, 48, 133}
- foodcords["barley"] = {-239, 48, 163}
- foodcords["asparagus"] = {-239, 48, 145}
- foodcords["bellpepper"] = {-229, 48, 143}
- foodcords["celery"] = {-209, 48, 143}
- foodcords["cucumber"] = {-199, 48, 143}
- foodcords["curryleaf"] = {-199, 48, 153}
- while true do
- if pcall(internetRequest()) then
- index, faction, item, amount = internetRequest()
- else
- index = false
- end
- if index == false then
- print("error")
- end
- if index ~= false then
- print(faction)
- print(item)
- print(amount)
- intAmount = tonumber(amount)
- moveName(item)
- transferAmount(intAmount)
- returnName(item)
- dumpInv(faction)
- deleteRequest()
- end
- os.sleep(5)
- end
Add Comment
Please, Sign In to add comment