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

Need Help With Programming Turtle From Direwolf20 S5 Ep24

Started by bishopb65, 03 September 2013 - 10:42 PM
bishopb65 #1
Posted 04 September 2013 - 12:42 AM
I know he has his stuff set up great, but I'm running the ultimate mod pack and not his. Makes things a little tougher to get. anyway heres the code


local location = ""

function teleport()
tp = peripheral.wrap("bottom")
tp.teleport()
end

function checkFull()
greader = peripheral.wrap("right")
data = greader.get()
while not data["Full Energy"] do
sleep(2)
data=greader.get()
end
turtle.dig()
end

function checkEmpty()
greader=peripheral.wrap("right")
data = greader.get()
while not data["No Energy"] do
sleep(2)
data = greader.get()
end
turtle.dig()
end

function checkLoc()
loc = turtle.detectUp()
if loc == true then
print("I am at the quarry")
location = "Quarry"
if turtle.getItemCount(1) > 0 then turtle.turnRight() end
else
print("I am at the charge station")
location = "Charging"
if turtle.getItemCount(1) > 0 then
turtle.turnRight()
turtle.forward()
turtle.forward()
end
end
end

function getFuel()
turtle.turnleft()
for i = 1, 8 do turtle.forward() end
turtle.turnLeft()
for i = 1, 2 do turtle.forward() end
turtle.suck()
turtle.refuel()
turtle.turnLeft()
turtle.turnLeft()
for i = 1, 2 do turtle.forward() end
turtle.turnRight()
for i = 1, 8 do turtle.forward() end
turtle.turnleft()
end


function checkFuel()
fuel = turtle.getFuelLevel()
print("My fuel level:"..tostring(fuel))

if fuel < 1000 then
print("I need fuel")
getFuel()
print("My fuel level:"..tostring(turtle.getFuelLevel()))
end
end


checkLoc()
if location == "Quarry" then
turtle.place()
checkEmpty()
teleport()
else
turtle.place()
checkFuel()
checkFull()
turtle.turnLeft()
turtle.turnLeft()
turtle.forward()
turtle.forward()
teleport()
end


i get…bios :338: [string "teleport"]:8: '='
expected
Lyqyd #2
Posted 04 September 2013 - 12:48 PM
Split into new topic.