Posted 03 January 2013 - 06:49 AM
Hey guys! I am kinda new in the turtles area, so I made a Dance 2.0 program to learn basics.
It has an auto-refueler.
EDIT: This was the best I could get it. I didn't know about loops when I made this code. I typed all of the original. Also, I included a certain code in the dancing function.
It has an auto-refueler.
-- Dance 2.0
-- By DJZ0404
-- This is my first venture into turtle programming.
-- EDITED 7/17/2013: Fixed it so it WOULD work. Also functioned it.
function refuel()
if turtle.getFuelLevel() > 200 then
turtle.select(1)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(2)
turtle.refuel(10)
if turtle.refuel == false then
turtle.select(3)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(4)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(5)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(6)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(7)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(8)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(9)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(10)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(11)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(12)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(13)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(14)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(15)
turtle.refuel(10)
if turtle.refuel() == false then
turtle.select(16)
turtle.refuel(10)
if turtle.refuel() == false then
print("No fuel detected. Stopping...")
term.clear()
term.setCursorPos(1, 1)
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
repeat
sleep(.5)
turtle.turnLeft()
turtle.up()
turtle.down()
print("Get down!")
sleep(.5)
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.up()
turtle.backward()
turtle.turnLeft()
sleep(.5)
print("Check me out, I'm dancin'")
sleep(.5)
turtle.turnLeft()
print("I'm dancin'")
turtle.up()
turtle.down()
turtle.down()
until turtle.getFuelLevel() > 200
refuel()
EDIT: This was the best I could get it. I didn't know about loops when I made this code. I typed all of the original. Also, I included a certain code in the dancing function.
-- Dance 2.0
-- By DanJZ0404
-- Fueling.
function refuel()
local ItemSlot = 1
repeat
turtle.select(ItemSlot)
turtle.refuel(1)
until(ItemSlot == 17 or turtle.refuel(1))
end
turtle.getFuelLevel()
if turtle.getFuelLevel() > 200 then
refuel()
end
-- Dance function
function dance()
turtle.up()
sleep(.5)
turtle.up()
sleep(.5)
turtle.down()
sleep(.5)
turtle.down()
sleep(.5)
turtle.left()
sleep(.5)
turtle.right()
sleep(.5)
turtle.left()
sleep(.5)
turtle.right()
end
if turtle.getFuelLevel < 200 then
repeat
dance()
until turtle.getFuelLevel > 200
end
I figured I would do this some justice. v3 here:
-- DanCe 3.0
-- by Dan
--Fueling code:
function refuel(fNum, slotNum)
for i = 1, slotNum do
turtle.select(slotNum)
turtle.refuel(fNum)
end
end
function dance()
turtle.up()
turtle.up()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.turnLeft()
turtle.forward()
turtle.back()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.back()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.back()
turtle.turnRight()
turtle.turnRight()
turtle.turnLeft()
turtle.up()
turtle.up()
end
press = os.pullEvent("char")
repeat
dance()
until press==28 or turtle.getFuelLevel() > 200