did stuff
This commit is contained in:
parent
d15dab5595
commit
bcae7eac08
134
src/brulijam/schmutz.lua
Normal file
134
src/brulijam/schmutz.lua
Normal file
@ -0,0 +1,134 @@
|
||||
basic = require("lib.basic")
|
||||
tutel = require("lib.tutel")
|
||||
|
||||
--dirty script for dirty dirt
|
||||
|
||||
oreList = {
|
||||
[0] = "minecraft:dirt",
|
||||
[1] = "minecraft:grass_block"
|
||||
}
|
||||
|
||||
keepList = {
|
||||
[0] = "minecraft:dirt",
|
||||
[1] = "minecraft:grass_block"
|
||||
}
|
||||
|
||||
local function isWanted(blockData)
|
||||
for i=0, #oreList do
|
||||
if blockData["name"] == oreList[i] then
|
||||
inventoryRework()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function inventoryRework()
|
||||
chestAvailable = false
|
||||
chestSlot = 0
|
||||
spaceAvailable = false
|
||||
|
||||
for i=1, 16 do
|
||||
turtle.select(i)
|
||||
itemDetail = turtle.getItemDetail()
|
||||
if itemDetail ~= nil then
|
||||
if itemDetail.name == "minecraft:coal" or itemDetail.name == "minecraft:charcoal" then
|
||||
turtle.refuel()
|
||||
spaceAvailable = true
|
||||
elseif itemDetail.name == "minecraft:chest" or itemDetail.name == "minecraft:barrel" then
|
||||
chestAvailable = true
|
||||
chestSlot = i
|
||||
else --check if item can be thrown away
|
||||
keepItem = false
|
||||
for j=0, #keepList do
|
||||
if itemDetail.name == keepList[j] then
|
||||
keepItem = true
|
||||
end
|
||||
end
|
||||
if not keepItem then
|
||||
turtle.dropDown()
|
||||
spaceAvailable = true
|
||||
end
|
||||
end
|
||||
else --at least one slot of space remaining
|
||||
spaceAvailable = true
|
||||
end
|
||||
end
|
||||
|
||||
--store items away
|
||||
if not spaceAvailable and chestAvailable then
|
||||
--turtle.up()
|
||||
tutel.up()
|
||||
basic.secureDigUp()
|
||||
--turtle.up()
|
||||
tutel.up()
|
||||
basic.secureDigUp()
|
||||
turtle.select(chestSlot)
|
||||
turtle.placeUp()
|
||||
--savePos("Chest placed at ")
|
||||
|
||||
for k=1, 16 do
|
||||
turtle.select(k)
|
||||
itemDetail = turtle.getItemDetail()
|
||||
if itemDetail ~= nil then
|
||||
if itemDetail.name ~= "minecraft:chest" and itemDetail.name ~= "minecraft:barrel" and itemDetail.name ~= "computercraft:wireless_modem_advanced" then
|
||||
turtle.dropUp()
|
||||
end
|
||||
end
|
||||
end
|
||||
--turtle.down()
|
||||
tutel.down()
|
||||
--turtle.down()
|
||||
tutel.down()
|
||||
end
|
||||
|
||||
if not spaceAvailable and not chestAvailable then
|
||||
--savePos("Turtle stopped")
|
||||
--local pos = tutel.getPos()
|
||||
--basic.ntfy("(Mining) " .. "Turtle stopped mining at " .. pos["x"] .. ", " .. pos["y"] .. ", " .. pos["z"])
|
||||
shell.run("delete /brulijam/task.lua")
|
||||
shell.run("reboot")
|
||||
end
|
||||
end
|
||||
|
||||
local function recursiveOreMining()
|
||||
for i=0, 3 do
|
||||
--turtle.turnLeft()
|
||||
tutel.left()
|
||||
blockFound, blockData = turtle.inspect()
|
||||
if isOre(blockData) then
|
||||
tutel.secureDig()
|
||||
--turtle.forward()
|
||||
tutel.forward()
|
||||
recursiveOreMining()
|
||||
--turtle.back()
|
||||
tutel.back()
|
||||
end
|
||||
end
|
||||
|
||||
blockFound, blockData = turtle.inspectUp()
|
||||
if isOre(blockData) then
|
||||
tutel.secureDigUp()
|
||||
--turtle.up()
|
||||
tutel.up()
|
||||
recursiveOreMining()
|
||||
--turtle.down()
|
||||
tutel.down()
|
||||
end
|
||||
|
||||
blockFound, blockData = turtle.inspectDown()
|
||||
if isOre(blockData) then
|
||||
tutel.secureDigDown()
|
||||
--turtle.down()
|
||||
tutel.down()
|
||||
recursiveOreMining()
|
||||
--turtle.up()
|
||||
tutel.up()
|
||||
end
|
||||
end
|
||||
|
||||
local function main()
|
||||
while true do
|
||||
recursiveOreMining()
|
||||
end
|
||||
end
|
@ -28,6 +28,8 @@ local copyList = {
|
||||
[20] = "/brulijam/t-fiboMiner.lua",
|
||||
[21] = "/brulijam/tutelMoveTest.lua",
|
||||
[22] = "/brulijam/files/shape-hex-64-10.svg",
|
||||
[23] = "/brulijam/schmutz.lua",
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user