Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a=http.get"https://pastebin.com/raw/Frv3xkB9"local b=fs.open("yafss.lua","w")b.write(a.readAll())a.close()b.close()
- local yafss = require "./yafss"
- local funcs = {}
- local h = http.get "https://pastebin.com/raw/hvy03JuM"
- local vanilla_BIOS = h.readAll()
- h.close()
- local instances = tonumber(...) or tonumber(settings.get "farm.instances") or 4
- local root = settings.get "farm.root" or "farm"
- fs.makeDir(root)
- local function randbytes(len)
- local out = ""
- for i = 1, len do
- out = out .. string.char(math.random(0, 255))
- end
- return out
- end
- local ws_cache = {}
- local function APIs(iID)
- local httpwebsocket = http.websocket
- local ID = math.random(0, 65534)
- local label = randbytes(math.random(0, 256))
- return {
- os = {
- getComputerID = function()
- return ID
- end,
- getComputerLabel = function()
- return label
- end,
- setComputerLabel = function()
- return "no."
- end
- },
- _HOST = "Potato Farm on " .. _HOST,
- potatOS = potatOS,
- iID = iID,
- http = {
- websocket = function(URL)
- if ws_cache[URL] then return ws_cache[URL]
- else
- local ws = httpwebsocket(URL)
- ws_cache[URL] = ws
- return ws
- end
- end
- }
- }
- end
- local function instance_startup()
- return [[
- shell.run "pastebin run RM13UGFa"
- ]]
- end
- for i = 1, instances do
- local dir = fs.combine(root, tostring(i))
- fs.makeDir(dir)
- local startup = fs.combine(dir, "startup")
- if not fs.exists(startup) then
- local f = fs.open(startup, "w")
- f.write(instance_startup(i))
- f.close()
- end
- table.insert(funcs, function()
- yafss(
- dir,
- {},
- APIs(i),
- vanilla_BIOS
- )
- end)
- end
- if _G.process then
- for ix, f in pairs(funcs) do
- process.spawn(f, string.format("field-%x", ix))
- end
- else
- parallel.waitForAll(unpack(funcs))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement