Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computerName = os.getComputerLabel()
- if not computerName then error("Please set the label of this computer") end
- local settings = {}
- local fileSettings = "settings.txt"
- shell.run("id")
- local files = {}
- local iLocal = 0
- local iGlobal = 0
- local apis = {
- gbMenu = {name="Glasses Bridge Menu", file="gbMenu", pbLink = "3phAmDLV"},
- goto = {name="Go To", file="goto", pbLink="i0i9fejL"},
- inventory = {name="Inventory", file="inventory", pbLink="3bMNrX57"},
- pt = {name="Table Serializer", file="pt", pbLink="xeJWhzhN"},
- termMenu = {name="Terminal Menu", file="termMenu", pbLink="imwqJg9N"},
- tools = {name="Common Tools", file="tools", pbLink="kkgiV37C"},
- }
- local tables = {
- items = {name="Items Table", file="items.tbl"},
- names = {name="Computer Names", file="names.tbl", pbLink = "UMb7exyE"},
- freqs = {name="Tesseract Frequencies", file="frequencies.tbl", pbLink = "ATyqWyKg"},
- recipes = {name="Recipes Table", file="recipes.tbl"}
- }
- local programs = {
- termInterface = {file="termInterface.lua", name="termInterface", pbLink="jFANs4S9", settings={
- {name="freqDropOff", desc="Name of tesseract frequency to use", t="string"}
- }
- },
- apps = {file="apps.lua", name="Apps", pbLink="xP4U7nDs", settings={
- {name="name", desc="Who will be using this turtle?", t="string"}
- }
- },
- sortMaster = {file="sortMaster.lua", name="Sort Master", pbLink="LbNcQ3S3", settings={
- {name="width", desc="How many storage units wide?", t="integer", lVal=0},
- {name="fuelName", desc="Type of fuel to use (ie Coal)", t="string"},
- {name="up", desc="Build the wall up or down?", t="boolean", lVal="down", hVal="up"},
- {name="tesseractDirection", desc="Direction from chest to tesseract (ie north)", t="string"}
- }
- },
- crafter = {file="crafter.lua", name="Crafter", pbLink="Eske6u4i", settings={}},
- retriever = {file="retriever.lua", name="Retreiver", pbLink="H2hD1Cqg", settings={
- {name="pushDir", desc="Direction from DSU to turtle (ie north)", t="string"},
- {name="xHome", desc="X Position or origin", t="integer", lVal=nil, hVal=nil},
- {name="yHome", desc="Y Position or origin", t="integer", lVal=nil, hVal=nil},
- {name="zHome", desc="Z Position or origin", t="integer", lVal=nil, hVal=nil},
- {name="minFuel", desc="Level at which to refuel", t="integer", lVal = 100},
- {name="maxFuel", desc="Level at which to stop refuelling", t="integer", lVal = 1000}
- }
- },
- lavaBuckets = {file="lavaBuckets.lua", name="Lava Buckets", pbLink=nil, settings={}},
- itemBuffer = {file="itemBuffer.lua", name="Item Buffer", pbLink="XSDW1Vrh", settings={
- {name="dropDir", desc="Direction to drop the items (up/down/fwd)", t="string"},
- {name="sleepTime", desc="Seconds to sleep before dropping items", t="integer", lVal=1, hVal=nil}
- }
- },
- sorter = {file="sorter.lua", name="Sorter", pbLink="gkbKFL2c", settings={
- {name="pushDir", desc="Direction from DSU to turtle (ie north)", t="string"},
- {name="xHome", desc="X Position or origin", t="integer", lVal=nil, hVal=nil},
- {name="yHome", desc="Y Position or origin", t="integer", lVal=nil, hVal=nil},
- {name="zHome", desc="Z Position or origin", t="integer", lVal=nil, hVal=nil}
- }
- },
- bridge = {file="bridge.lua", name="Bridge", pbLink="TSxdHwzW", settings={}},
- engineMonitor = {file="engineMonitor.lua", name="Engine Monitor", pbLink="zzfmkbK9", settings={}},
- engineStack = {file="engineStack.lua", name="Engine Stack", pbLink="5gwVvR04", settings={
- {name="stackNum", desc="Which stack of engines is this?", t="integer"},
- {name="lowLevel", desc="Level to turn the engines back on", t="integer", lVal=0, hVal=100},
- {name="highLevel", desc="Level to turn the engines off", t="integer", lVal=0, hVal=100},
- {name="batSide", desc="Which side the battery is on", t="string"},
- {name="cableSide", desc="Which side the rednet cable is on", t="string"},
- {name="sleepTime", desc="Time between taking readings", t="integer", lVal=1}
- }
- },
- grapher = {file="grapher.lua", name="Grapher", pbLink="c38hZ7yA", settings={}},
- oilL = {file="oilL.lua", name="Oil Well Large", pbLink="KDUw1Zne", settings={}},
- tunnel = {file="tunnel.lua", name="Tunnel", pbLink="GqXCYPta", settings={}},
- turtleMonitor = {file="turtleMonitor.lua", name="Turtle Monitor", pbLink="W8VrYsZj", settings={}},
- startup = {file="startup", name="Startup", pbLink="ZzHfdqdA", settings={}},
- queue = {file="queue.lua", name="Item Queue", pbLink="DWPDXv58", settings={
- {name="gbNum", desc="terminal_glasses_bridge_X", t="integer", lVal=0}
- }
- },
- gbInterface = {file="gbInterface.lua", name="Glasses Bridge Interface", pbLink="C8bfDE9U", settings={
- {name="defaultDest", desc="Name of tesseract freq to default to", t="string"},
- {name="destResetDelay", desc="Time to wait before reseting to default (s)", t="integer", lVal = 10},
- {name="gbNum", desc="terminal_glasses_bridge_X", t="integer", lVal=0}
- }
- },
- itemID = {file="itemID.lua", name="Item Identifier", pbLink="0NrC60wJ", settings={}},
- wallBuilder = {file="wallBuilder.lua", name="Wall Builder", pbLink="gMZeRLbR", settings={}},
- fuelSupply = {file="fuelSupply.lua", name="Fuel Supplier", pbLink="SbzXmTQv", settings={
- {name="pushDir", desc="Direction from DSU to tesseract (ie north)", t="string"}
- }
- },
- dutyCycle = {file="dutyCycle.lua", name="Duty Cycle", pbLink="H0KkGPSY", settings={
- {name="period", desc="Period of cycle (s)", t="integer", lVal=0},
- {name="dutyCycle", desc="Percent of time to be on", t="integer", lVal=0, hVal=100},
- {name="outputSide", desc="Side to output redstone (ie top)", t="string"},
- {name="onState", desc="Is on high or low?", t="boolean", hVal="high", lVal="low"}
- }
- },
- topOff = {file="topOff.lua", name="Top Off", pbLink="EJJrE9zp", settings={
- {name="pSide", desc="Side of peripheral (ie top)", t="string"},
- {name="amount", desc="Amount to order when empty", t="integer", lVal=0, hVal=1024},
- {name="itemName", desc="Name of item (ie Coal)", t="string"},
- {name="invSlot", desc="Slot of peripheral to monitor", t="integer", lVal=0},
- {name="sleepTime", desc="Seconds between checking", t="integer", lVal=0},
- {name="freqName", desc="Name of tesseract frequency", t="string"}
- }
- }
- }
- local function fileNames(tbl)
- local pathGlobal = "/rom/shared/"
- local pathLocal = "/files/"
- for k,v in pairs(tbl) do
- if fs.exists(v.file) then
- --No need to change the location
- files[k] = v.file
- iLocal = iLocal + 1
- elseif fs.exists(pathGlobal..v.file) then
- --Use global location
- files[k] = pathGlobal..v.file
- iGlobal = iGlobal + 1
- elseif fs.exists(pathLocal..v.file) then
- --Use local shared folder
- files[k] = pathLocal..v.file
- iLocal = iLocal +1
- elseif v.pbLink then
- print("Downloading "..v.name.." from pasteBin")
- if not fs.exists(pathLocal) then fs.makeDir(pathLocal) end
- local s = pathLocal..v.file
- shell.run("pastebin", "get", v.pbLink, s)
- sleep(1)
- files[k] = s
- iLocal = iLocal + 1
- else
- print(v.file.." not found")
- end
- end
- end
- --[[ Prompts the user for the desired settings ]]
- function promptSettings(rS, progName)
- local fSettings = fs.open("settings.txt", "w")
- os.loadAPI(files.termMenu)
- local w, h = term.getSize()
- termMenu.new(2,2,w-2,h-2,term)
- for i=1,#rS do
- termMenu.drawBox(1,1,1,1)
- termMenu.printCenterX(1, progName.." needs "..rS[i].t)
- termMenu.printCenterX(2, rS[i].desc)
- local input ="no"
- if rS[i].t == "integer" then
- input = termMenu.getInputNum(rS[i].name, rS[i].lVal, rS[i].hVal)
- elseif rS[i].t == "boolean" then
- input = termMenu.getInputBoolean(rS[i].name, rS[i].hVal, rS[i].lVal)
- elseif rS[i].t == "string" then
- input = termMenu.getInputString(rS[i].name)
- end
- if type(input)~="string" then input = tostring(input) end
- fSettings.writeLine("#"..rS[i].desc)
- fSettings.writeLine(rS[i].name.."="..input)
- end
- fSettings.close()
- end
- local function getSettings()
- if fs.exists(fileSettings) then
- file = fs.open(fileSettings, "r")
- local count = 0
- local line = file.readLine()
- while line ~= nil do
- if string.sub(line, 1, 1)~="#" then --# is comment character
- local split, split2 = string.find(line, "=")
- local key = string.sub(line, 1, split-1)
- local value = string.sub(line, split+1)
- local n = tonumber(value)
- if n~=nil then value = n end
- if value=="true" then value = true end
- if value=="false" then value = false end
- settings[key] = value
- count = count + 1
- end
- line = file.readLine()
- end
- file.close()
- print("Loaded "..count.." settings")
- elseif next(programs[computerName].settings) then
- promptSettings(programs[computerName].settings, computerName)
- os.reboot()
- else
- print("No settings needed")
- end
- end
- if not programs[computerName] then error(computerName.." not in list of programs") end
- print("Checking for APIs")
- fileNames(apis)
- print("Checking for Tables")
- fileNames(tables)
- print("Checking for Programs")
- fileNames(programs)
- print("Getting settings")
- getSettings()
- sleep(.1)
- if fs.exists(files[computerName]) then
- print(files[computerName])
- --sleep(2)
- return os.run({settings = settings, files = files, idMe = os.computerID()}, files[computerName])
- else
- error(files[computerName].." not found")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement