Skip to content
Snippets Groups Projects
Commit 5dd8ace2 authored by Rodrigo Amaral's avatar Rodrigo Amaral
Browse files

V1.5

parent 6fe5b6e2
Branches buttons!
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ local N_COLS = 4 ...@@ -8,6 +8,8 @@ local N_COLS = 4
local FUEL_LOW_LIMIT = 2096 local FUEL_LOW_LIMIT = 2096
-- Amount of fuel items consumed on a single refuel -- Amount of fuel items consumed on a single refuel
local REFUEL_AMOUNT = 4 local REFUEL_AMOUNT = 4
-- Minimum stack size for fuel item (on slot 1)
local N_FUEL_STOCK = 8
-- Amount of layers of N_ROWS by N_COLS wide to be dug, if 0 then infinite amount of layers -- Amount of layers of N_ROWS by N_COLS wide to be dug, if 0 then infinite amount of layers
-- Relative to what? Layer (y) at which turtle starts, buddy -- Relative to what? Layer (y) at which turtle starts, buddy
...@@ -28,19 +30,6 @@ function Is_Even(num) ...@@ -28,19 +30,6 @@ function Is_Even(num)
end end
end end
-- Performs a fuel check and attempts to refuel from slot 1
function Fuel_Check()
local fuel_level = turtle.getFuelLevel()
if fuel_level < FUEL_LOW_LIMIT then
turtle.select(1)
if(not turtle.refuel(REFUEL_AMOUNT)) then
print("Couldn't Refuel Turtle!'")
return false
end
end
return true
end
-- Checks if slot 16 has an item, returns true if so -- Checks if slot 16 has an item, returns true if so
function Check_FullInv() function Check_FullInv()
if (turtle.getItemCount(16) == 0) then if (turtle.getItemCount(16) == 0) then
...@@ -57,19 +46,46 @@ function Place_Items() ...@@ -57,19 +46,46 @@ function Place_Items()
turtle.select(i) turtle.select(i)
turtle.drop() turtle.drop()
end end
turtle.select(1)
end
function Restock_Fuel()
turtle.turnRight()
turtle.suck(turtle.getItemSpace(1))
turtle.turnLeft()
end end
function Inventory_Routine() -- Goes home, unloads items and goes back
function Home_Routine()
--Check if Last Inventory spot is used, if so unload --Check if Last Inventory spot is used, if so unload
if(Check_FullInv()) then if(Check_FullInv()) then
Go_Home() Go_Home()
Place_Items() Place_Items()
Restock_Fuel()
turtle.turnLeft() turtle.turnLeft()
turtle.turnLeft() turtle.turnLeft()
Go_Back() Go_Back()
end end
end end
-- Performs a fuel check and attempts to refuel from slot 1
function Fuel_Check()
local fuel_level = turtle.getFuelLevel()
if fuel_level < FUEL_LOW_LIMIT then
turtle.select(1)
-- Restock Fuel if fuel stock below N_FUEL_STOCK
if(turtle.getItemCount(1) < N_FUEL_STOCK) then
Home_Routine()
end
if(not turtle.refuel(REFUEL_AMOUNT)) then
print("Couldn't Refuel Turtle!'")
return false
end
end
return true
end
-- Tries to dig in front of turtle, if inventory is full empties the inventory at home and then returns -- Tries to dig in front of turtle, if inventory is full empties the inventory at home and then returns
function Dig_Infront() function Dig_Infront()
local r, err = turtle.dig() local r, err = turtle.dig()
...@@ -349,7 +365,7 @@ function Mine_1Layer() ...@@ -349,7 +365,7 @@ function Mine_1Layer()
Count_Row() Count_Row()
-- Check if inventory is full -- Check if inventory is full
Inventory_Routine() Home_Routine()
end end
-- turn -- turn
...@@ -381,7 +397,7 @@ function Mine_1Layer() ...@@ -381,7 +397,7 @@ function Mine_1Layer()
turtle.turnRight() turtle.turnRight()
end end
Inventory_Routine() Home_Routine()
Fuel_Check() Fuel_Check()
end end
...@@ -395,7 +411,7 @@ function Mine_1Layer() ...@@ -395,7 +411,7 @@ function Mine_1Layer()
Count_Row() Count_Row()
-- Check if inventory is full -- Check if inventory is full
Inventory_Routine() Home_Routine()
end end
return 0 return 0
...@@ -429,6 +445,8 @@ function Main() ...@@ -429,6 +445,8 @@ function Main()
end end
CURRENT_LAYER = CURRENT_LAYER + 1 CURRENT_LAYER = CURRENT_LAYER + 1
Home_Routine()
end end
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment