ok this is what i have so far ( if figure if i share it all it may help others and you guys may spot any mistakes) this is far from the finished code though but all 3 scripts work so long as its not obstructed (ill get to that in the question part of my post lol)
first i got fed up with going into lua entering the cords making it face the right way etc so i wrote a config script called cfg
print ("manual config script for turtle reboot")
print ("enter x cords first number on minimap")
x = io.read()
x = tonumber(x)
print("enter y cords (height)")
y = io.read()
y = tonumber(y)
print("enter z cords last number")
z = io.read()
z = tonumber(z)
term.write ("set to ")
term.write (x..",")
term.write (y..",")
term.write (z)
function nf()
print ("")
print ("am i facing north now? yes/no")
q1 = io.read()
if q1 == "yes" then
magicTurtle.setNorth()
else
magicTurtle.turnLeft()
nf()
end
end
magicTurtle.setPos(x,y,z)
nf()
magicTurtle.savePos()
print ("all done")
then as each time it got into postion at my base i had to instruct it to leave by hand i wrote this
gp (goto pos cos when i called it goto it conflicted with a default program)
print ("lets send this turtle")
print ("enter x cords first number on minimap")
x = io.read()
x = tonumber(x)
print("enter y cords (height)")
y = io.read()
y = tonumber(y)
print("enter z cords last number")
z = io.read()
z = tonumber(z)
print ("mine on the way? true/false")
m = io.read()
term.write ("set to ")
term.write (x..",")
term.write (y..",")
term.write (z)
print ("")
print ("mining set to "..m)
print ("ok stand back and ill be on my way in 5")
sleep(5)
magicTurtle.goToPos(x,y,z,m)
then the main program itself the gohome script (rednet stuff untested yet)
-- reference 77 285 286 303 144
function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
os.reboot()
end
return event, p1, p2, p3, p4, p5
end
function gohome()
magicTurtle.savePos()-- for ease of use latter and incase of crash
tim=0
tim2=0
print ("Im off home")--i will make these print to a master terminal as well in the final version :unsure:/>/>
local x,y,z=magicTurtle.getPos()
flyup()
--ok so were at 120 lets go near the base
magicTurtle.goToPos(19590,120,489,false) --not the actual cords but close enough for goverment work false so it wont break anything
--now we need it to go down to 78
print ("Descending")
magicTurtle.goToPos(19590,78,493,false)
--now to make it go to the door
magicTurtle.goToPos(19590,79,423,false)
--now to make it open the door
print("knock knock, room for a poor old turtle?")
rednet.open("back") --should be open already on the main script?
rednet.send(303, "littlecomputerletmein")
outerdock() -- right lets get the little turtle through the door
indock() -- we wait for the door to close
unload() -- unload the stuff
print ("cycle complete, sleepy turtle sleep now?")
sleep(60)
os.shutdown()
end
function flyup()
print ("Up up and awaaaaay")
magicTurtle.savePos()-- for ease of use latter and incase of crash
local x,y,z=magicTurtle.getPos()
magicTurtle.goToPos(x,120,z,true)
--if y == 120 then --can make that 250 when we get the anvil B)/>/>
--end
--else magicTurtle.up(1)
--flyup()
--end
end
function outerdock()
magicTurtle.savePos()-- for ease of use latter and incase of crash
detect=turtle.detect()
if detect == false then --make sure the doors open first wouldnt want him to bang his nose errr screen
--magicTurtle.goToPos(19590,79,421,false) --gets a bit confused bless him
magicTurtle.forward(2) --1 into the hole 1 through it)
else
tim = tim + 1
if tim == 60 then
print ("ummm boss we got us a problem")
else
sleep(1)
outerdock()
end
end
end
function indock()
magicTurtle.savePos()-- for ease of use latter and incase of crash
magicTurtle.faceSouth() --faces the door as thier is no detect back (oops)
detect2=turtle.detect()
if detect2 == true then --wait for the door to close behind us
-- magicTurtle.goToPos(19495,79,417,false) -- api dosnt like going to cords in a confined space
magicTurtle.faceNorth() --face away from the door
magicTurtle.forward(4) -- fly 4 squares into the room
magicTurtle.faceEast() -- so he is looking at his docking station
magicTurtle.forward(5) -- fly to his docking port
magicTurtle.faceWest() -- face into the room with his back resting on the filtier
magicTurtle.savePos()-- for ease of use latter and incase of crash
else tim2 = tim2 + 1
if tim2 == 60 then
print("come on close the door its cold in here")
else
sleep(1)
indock()
end
end
end
function unload()
magicTurtle.savePos()-- for ease of use latter and incase of crash (though this should be the same as outerdock one)
--redpulse back 9 -- red pulse doesnt work from scripts
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
redstone.setOutput("back",true)
sleep(1)
redstone.setOutput("back",false)
sleep(1)
print ("i feel as light as a feather now")
end
gohome()
notes:
seeing the turtle face the open door and watch it till it closed was a cool side feature just looks good, as does seeing it coming in to dock (memories of elite dar darrrrr da dar dar, dar dar (old gamers will know the tune im humming)
all the print messages will be going to a terminal in my base (eventualy up on a big screen dan showed in 1.31 preview pic (man that looks good)
questions:
1) how do i tell it to go around obsticles when it is obstructed during a gopos command? or at least error out and yell for help ? (if i could make it run another function if obstructed then i could have it broadcast its cords to a base computer (cant wait for those big terminals! help help turtle on its shell at x y z B)/>/> )
2) is there a way to make it use cords out of text file instead of the ones i have hard coded ? (would make it easier for others that may want to use my script)
3) why oh why does redpulse not work in a script?
4) ok i have the go home program but how do i call the program from another program? (so when the turtle is full or recieves the recall signal it executes gohome
also thnx for the help thus far guys, with out you and this forum i wouldnt of been able to get as much as i have working!