191 posts
Posted 02 July 2013 - 09:42 AM
I made a mining turtle months ago and uploaded it here, it keeps trak of its coordinates using the file system.
This is part of my code
while turtle.forward() == false do
turtle.attack()
turtle.dig()
end
Increment variables depending on direction
save()
the thing is that if the chunk unloads when it is moving it doesent do the coordinate thing.
Fix? Maybe using the paralell API?
130 posts
Posted 02 July 2013 - 10:04 AM
You should look at this thread for reloading coordinates:
http://www.computerc...s-world-reload/
191 posts
Posted 02 July 2013 - 10:24 AM
Wouldnt that break if it moves up or down?
191 posts
Posted 02 July 2013 - 10:33 AM
I suppose a complete rewrite of my turtle is coming up now :D/>
1522 posts
Location
The Netherlands
Posted 02 July 2013 - 10:37 AM
You know you can be very, very sneaky with this. I mean, you can 'rewrite' the turtle.<direction> functions!
local turtleUp = turtle.up
turtle.up = function()
--# Do stuff, the coords system in this case
turtleUp()
end
--# A rough example (nothing to due with coords, just showcase what you can do with it)
local turtleUp = turtle.up
turtle.up = function( time )
if type( tonumber(time) ) ~= "number" then error("Number expected, got " .. type( tonumber(time) ), 2 ) end
for i = 1, tonumber(time) do
turtleUp()
end
end
But, what if another program uses turtle.up()? Well, we change it back to the original when the program quits:
turtle.up = turtleUp
After you have done that, you can use all programs just like you would normally. Also a tip:
local turtleUp = turtle.up
turtle.up = function()
if turtleUp() then
--# only do it when we actually moved! Very important!
end
end