Jump to content




Troubles with persistence


  • You cannot reply to this topic
4 replies to this topic

#1 Cycomantis

  • Members
  • 60 posts

Posted 15 February 2014 - 07:16 AM

I'm using the following bit of code to track my turtles movements when it is mining. Sometimes when he is unloaded and then reloaded and starts back up he will have moved but his coordinates did not get updated. Is there a better way to do it?

function up( steps )
local steps = steps or 1
for x = 1, steps do
  tCoords["y"] = tCoords["y"] + 1
  savePos()  --just a function that serialize the table and save it to a file
  while not turtle.up() do
    turtle.digUp()
    turtle.attackUp()
    sleep(.1)
  end
end
end


#2 Molinko

  • Members
  • 54 posts

Posted 15 February 2014 - 03:11 PM

whenever a Turtle is moving in multiplayer at the server shutdown there is as chance that the turtle can finish a turtle.native call and exit the current function before you can check the result of the call and save accordingly.. there its an API called "Lama" on the forums which uses fuel calculation and custom startup scripts fir each call to a call that changes the turtle position. It can be a bit taxing on execution time. With that said, its a very clever solution.


#3 Cycomantis

  • Members
  • 60 posts

Posted 15 February 2014 - 04:34 PM

Thank you I will take a look at Lama and see if I can implement something similar.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 February 2014 - 07:00 PM

My preferred method is to use the GPS API to get the turtle's location on boot, rather then loading it from a file. This has the advantage of removing all need to write it to the drive at all, though depending on the sort of tasks the turtle performs, you may still need to record eg which way it was going etc.

#5 Cycomantis

  • Members
  • 60 posts

Posted 16 February 2014 - 01:19 AM

View PostBomb Bloke, on 15 February 2014 - 07:00 PM, said:

My preferred method is to use the GPS API to get the turtle's location on boot, rather then loading it from a file. This has the advantage of removing all need to write it to the drive at all, though depending on the sort of tasks the turtle performs, you may still need to record eg which way it was going etc.

I have been debating on doing that exact thing, but maybe more as a verification tool then for the entire movement tracking.

The turns and direction he is facing is something that I'm having issues with as well. It sucks when he turns and mines over an area he has already mined due to not counting the turns correctly. Do you have any tips other then doing the update prior to the physical move? Right now I'm testing that method and it seems to be working for the most part.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users