From 193ce1da41a96f27e2694eea5cbd8cd8c91af223 Mon Sep 17 00:00:00 2001 From: brulijam Date: Sat, 8 Jun 2024 19:15:43 +0200 Subject: [PATCH] . --- src/brulijam/lib/basic.lua | 4 +- src/brulijam/turtle-miner-fibo.lua | 92 +----------------------------- src/startup.lua | 14 ++++- 3 files changed, 17 insertions(+), 93 deletions(-) diff --git a/src/brulijam/lib/basic.lua b/src/brulijam/lib/basic.lua index 8aafa0d..0619908 100755 --- a/src/brulijam/lib/basic.lua +++ b/src/brulijam/lib/basic.lua @@ -49,10 +49,10 @@ function ntfy(msg) http.post("https://ntfy.brammer.cc/8DI2nmDPVG6l7A0x", msg) end -function splitStringToArray(input_str) +function splitStringToArray(inputStr) table = {} i = 0 - for str in string.gmatch(input_str, "([^"..",".."]+)") do + for str in string.gmatch(inputStr, "([^"..",".."]+)") do table[i] = str i = i + 1 end diff --git a/src/brulijam/turtle-miner-fibo.lua b/src/brulijam/turtle-miner-fibo.lua index 3f15ceb..078158b 100644 --- a/src/brulijam/turtle-miner-fibo.lua +++ b/src/brulijam/turtle-miner-fibo.lua @@ -150,96 +150,6 @@ local function inventoryRework() end -local function clearInventory() - for i=1, 16 do - turtle.select(i) - itemDetail = turtle.getItemDetail() - local keepItem = false - - for j=0, #keepList do - itemDetail = turtle.getItemDetail() - if itemDetail ~= nil then - if itemDetail.name == keepList[j] then - --turtle.dropDown() - keepItem = true - end - end - end - - if not keepItem then - turtle.dropDown() - end - end - turtle.select(1) -end - -local function storeItems() - --refuel all - -- shell.run("refuel all") doesnt work because nomnom chests - for i=1, 16 do - turtle.select(i) - itemDetail = turtle.getItemDetail() - if itemDetail ~= nil then - if itemDetail.name == "minecraft:coal" then - turtle.refuel() - end - end - end - - --check inv for chest and place it - chestAvailable = false - for i=1, 16 do - turtle.select(i) - itemDetail = turtle.getItemDetail() - if itemDetail ~= nil then - if itemDetail.name == "minecraft:chest" then - turtle.up() - basic.secureDigUp() - turtle.up() - basic.secureDigUp() - turtle.placeUp() - savePos() - chestAvailable = true - break - elseif i == 16 then - --TODO save in state that no chests are available - shell.run("delete /brulijam/task.lua") - shell.run("reboot") - end - end - end - - --drop items in chest - if chestAvailable then - for i=1, 16 do - turtle.select(i) - itemDetail = turtle.getItemDetail() - if itemDetail ~= nil then - if itemDetail.name ~= "minecraft:chest" and itemDetail.name ~= "computercraft:wireless_modem_advanced" then - turtle.dropUp() - end - end - end - turtle.down() - turtle.down() - end -end - -local function checkInventory() - for i=1, 16 do - turtle.select(i) - itemCount = turtle.getItemCount() - if itemCount == 0 then - turtle.select(1) - return - end - end - - storeItems() - turtle.select(1) -end - - local function isOre(blockData) for i=0, #oreList do if blockData["name"] == oreList[i] then @@ -378,4 +288,6 @@ local function mineFibo() end end + +setup() mineFibo() \ No newline at end of file diff --git a/src/startup.lua b/src/startup.lua index cfeddfd..e53cfec 100644 --- a/src/startup.lua +++ b/src/startup.lua @@ -1,6 +1,11 @@ +--you may change these values +local repo = "https://git.brulijam.com/brulijam/Computercraft/raw/branch/main/src" +local labelPrefix = "SPHEAL" + + + --fetch sync script -local repo = "https://git.brulijam.com/brulijam/Computercraft/raw/branch/main/src" getRequest = http.get(repo .. "/brulijam/sync.lua") file = fs.open("/brulijam/sync.lua", "w") file.write(getRequest.readAll()) @@ -19,6 +24,13 @@ shell.run("brulijam/task.lua") --execute sync script shell.run("/brulijam/sync.lua") + +--set label if not set +if os.getComputerLabel == nil then + local labelMainPart = string.sub(hash.digestStr(os.getComputerID()), 1, 6) + os.setComputerLabel(labelPrefix .. "-" .. labelMainPart) +end + --shell.run("/brulijam/systemlock.lua")