Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Rod_Quarry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
roaa1g19
Rod_Quarry
Commits
5dd8ace2
Commit
5dd8ace2
authored
3 years ago
by
Rodrigo Amaral
Browse files
Options
Downloads
Patches
Plain Diff
V1.5
parent
6fe5b6e2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Rod_Quarry.lua
+35
-17
35 additions, 17 deletions
Rod_Quarry.lua
with
35 additions
and
17 deletions
Rod_Quarry.lua
+
35
−
17
View file @
5dd8ace2
...
...
@@ -8,6 +8,8 @@ local N_COLS = 4
local
FUEL_LOW_LIMIT
=
2096
-- Amount of fuel items consumed on a single refuel
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
-- Relative to what? Layer (y) at which turtle starts, buddy
...
...
@@ -28,19 +30,6 @@ function Is_Even(num)
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
function
Check_FullInv
()
if
(
turtle
.
getItemCount
(
16
)
==
0
)
then
...
...
@@ -57,19 +46,46 @@ function Place_Items()
turtle
.
select
(
i
)
turtle
.
drop
()
end
turtle
.
select
(
1
)
end
function
Restock_Fuel
()
turtle
.
turnRight
()
turtle
.
suck
(
turtle
.
getItemSpace
(
1
))
turtle
.
turnLeft
()
end
function
Inventory_Routine
()
-- Goes home, unloads items and goes back
function
Home_Routine
()
--Check if Last Inventory spot is used, if so unload
if
(
Check_FullInv
())
then
Go_Home
()
Place_Items
()
Restock_Fuel
()
turtle
.
turnLeft
()
turtle
.
turnLeft
()
Go_Back
()
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
function
Dig_Infront
()
local
r
,
err
=
turtle
.
dig
()
...
...
@@ -349,7 +365,7 @@ function Mine_1Layer()
Count_Row
()
-- Check if inventory is full
Inventory
_Routine
()
Home
_Routine
()
end
-- turn
...
...
@@ -381,7 +397,7 @@ function Mine_1Layer()
turtle
.
turnRight
()
end
Inventory
_Routine
()
Home
_Routine
()
Fuel_Check
()
end
...
...
@@ -395,7 +411,7 @@ function Mine_1Layer()
Count_Row
()
-- Check if inventory is full
Inventory
_Routine
()
Home
_Routine
()
end
return
0
...
...
@@ -429,6 +445,8 @@ function Main()
end
CURRENT_LAYER
=
CURRENT_LAYER
+
1
Home_Routine
()
end
return
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment