This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ThePH's profile picture

ThePH's programs (Count: 1)

Started by ThePH, 29 February 2012 - 06:08 PM
ThePH #1
Posted 29 February 2012 - 07:08 PM
I will post the programs/APIs I will make here with a brief description.
Feel free to use or modify any of them as long as you give me credit B)/>/>/>

Turtle ++ API

A small API that lets you use the basic turtle API but with params like tpp.forward(5) instead of using loops.
More features comming soon.
Type tpp.help() in lua to list the functions available.

[attachment=57:tpp.txt]

Code :
Spoiler

function help()
print("===Turtle ++ API===")
print("Uses/function list")
print("tpp.forward(n)")
print("tpp.back(n)")
print("tpp.up(n)")
print("tpp.down(n)")
print("tpp.left(n)")
print("tpp.right(n)")
print("tpp.dig(n)")
print("tpp.digUp(n)")
print("Press enter")
read()
print("tpp.digDown(n)")
print("tpp.place(n)")
print("tpp.placeUp(n)")
print("tpp.placeDown(n)")
print("tpp.clearInv()")
print("More comming soon :unsure:/>/>/>")
end
function forward(n)
turtle.forward()
if n ~= nil then
  for i=2,n do
   turtle.forward()
  end
end
end
function back(n)
turtle.back()
if n ~= nil then
  for i=2,n do
   turtle.back()
  end
end
end
function up(n)
turtle.up()
if n ~= nil then
  for i=2,n do
   turtle.up()
  end
end
end
function down(n)
turtle.down()
if n ~= nil then
  for i=2,n do
   turtle.down()
  end
end
end
function left(n)
turtle.turnLeft()
if n ~= nil then
  for i=2,n do
   turtle.turnLeft()
  end
end
end
function right(n)
turtle.turnRight()
if n ~= nil then
  for i=2,n do
   turtle.turnRight()
  end
end
end
function dig(n)
turtle.dig()
turtle.forward()
if n ~= nil then
  for i=2,n do
   turtle.dig()
   turtle.forward()
  end
end
end
function digUp(n)
turtle.digUp()
turtle.up()
if n ~= nil then
  for i=2,n do
   turtle.digUp()
   turtle.up()
  end
end
end
function digDown(n)
turtle.digDown()
turtle.down()
if n ~= nil then
  for i=2,n do
   turtle.digDown()
   turtle.down()
  end
end
end
function place(n)
turtle.place()
if n ~= nil then
  for i=2,n do
   turtle.back()
   turtle.place()
  end
end
end
function placeDown(n)
turtle.down()
turtle.placeUp()
if n ~= nil then
  for i=2,n do
   turtle.down()
   turtle.placeUp()
  end
end
end
function placeUp(n)
turtle.up()
turtle.placeDown()
if n ~= nil then
  for i=2,n do
   turtle.up()
   turtle.placeDown()
  end
end
end
function clearInv()
for i=1,9 do
  turtle.select(i)
  turtle.drop()
end
turtle.select(1)
end
Wolvan #2
Posted 29 February 2012 - 07:45 PM
Nice. And you install that API how? Never installed 1 before
Liraal #3
Posted 29 February 2012 - 07:48 PM
download it and type sth like os.loadAPI(filepath)
ThePH #4
Posted 29 February 2012 - 08:01 PM
Or just put it in "mods/computercraft/lua/rom/apis/turtle/" and it will load on every turtle you place use
Wolvan #5
Posted 29 February 2012 - 08:15 PM
Hey thx I test it out :unsure:/>/>