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

How to set xpos for the whole turtle?

Started by SimPlaysGames, 28 November 2014 - 05:29 PM
SimPlaysGames #1
Posted 28 November 2014 - 06:29 PM
Hey does anyone know how to set use these in two diffrent programs.
local xPos,zPos = 0,0
local xDir,zDir = 0,1
I want to run a program that set this pos, and then later run another program like excavate. The last program should know where the xPos and zPos is
Edited on 28 November 2014 - 05:30 PM
KingofGamesYami #2
Posted 28 November 2014 - 08:19 PM
@Lyqyd - shouldn't this be in Ask a Pro?

You would probably be best overriding the turtle movement functions.

--#backup stuff
local oldt = {}
for k, v in pairs( turtle ) do
 oldt[ k ] = v
end

turtle.forward = function()
  if oldt.forward() then
    --#set variables
    return true
  end
  return false
end

--#and so on, for all other movement.

Something to consider: You'll also want to track where the turtle is facing. Check out some other programs that track movements, if you need ideas.
Lyqyd #3
Posted 28 November 2014 - 09:59 PM
@Lyqyd - shouldn't this be in Ask a Pro?

Please use the report button.

Moved to Ask a Pro.