Posted 10 April 2013 - 08:37 AM
Turtle2
Turtle 2 v 0.1.3 alpha.
- 0.0.1 Release
- 0.0.2 Release
- 0.1.1 Release
- 0.1.3 Release
I will be adding more features.
Features -
Spoiler
Version() : Returns turtle2 version
Forward(x) : Moves forward x blocks, returns false if doesn't have significant fuel.
Back(x) : Moves back x blocks, returns false if doesn't have significant fuel.
Up(x) : Moves up x blocks, returns false if doesn't have significant fuel.
Down(x) : Moves down x blocks, returns false if doesn't have significant fuel.
isValuable(slots) : -WIP- Does not work yet. Returns the value of the block in front.
clearLine(x) : Digs a line.
Drop(count, slot) : Selects the slot and drops materials. Returns false if count is greater then the number of materials to drop. With turtle.drop(count) if the space selected was 3 and 3 didnt match the count it would drop materials form the 1st space. This works around it.
Refuel(amount, slot) : Selects the slot where fuel is located then refuels turtle with amount given in the first argument.
Install:
Spoiler
Copy the code from api spoiler into a text editor and save it as turtle2 into folder
: mods/computercraft/lua/rom/apis/turtle
Usage:
Spoiler
To use the turtle 2 API, first install it. Then call any function with turtle2.ex: turtle2.forward(10) Make sure to complete the required arguments for the function
Changelog:
Spoiler
V 0.0.2Spoiler
+ Version
+ Drop
- Fixed end in clearLine
- Removed fuel messages in move functions
V 0.1.1
Spoiler
+ refuelSpoiler
+ Return true functionality to functionsSpoiler
function version()
return "0.1.3"
end
function forward(x)
fuel = turtle.getFuelLevel()
if fuel < x then
return false
else
for i = 1, x do
turtle.forward()
return true
end
end
end
function back(x)
fuel = turtle.getFuelLevel()
if fuel < x then
return false
else
for i = 1, x do
turtle.back()
return true
end
end
end
function up(x)
fuel = turtle.getFuelLevel()
if fuel < x then
return false
else
for i = 1, x do
turtle.up()
return true
end
end
end
function down()
fuel = turtle.getFuelLevel()
if fuel < x then
return false
else
for i = 1, x do
turtle.down()
return true
end
end
end
function isValuable(slots)
nonvalue = false
for i = 1, slots do
turtle.select(i)
if turtle.compare() then
nonvalue = true
end
end
if nonvalue == true then
return false
else
return true
end
end
function clearLine(x)
fuel = turtle.getFuelLevel()
if fuel < x then
return false
else
moved = 0
for i = 1, x do
turtle.dig()
turtle.forward()
moved = moved + 1
end
turtle2.back(moved)
return true
end
end
function drop(count, slot)
items = turtle.getItemCount(slot)
if items < count then
return false
else
turtle.select(slot)
turtle.drop(count)
return true
end
end
function refuel(amount, slot)
items = turtle.getItemCount(slot)
if items < count then
return false
else
turtle.select(slot)
turtle.refuel(amount)
return true
end
end