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

Gps Locate, Turtle GoTo Problem

Started by igelbasis, 11 December 2013 - 04:07 AM
igelbasis #1
Posted 11 December 2013 - 05:07 AM
Hi there,

I am trying to build my own goto script and clash on the first issue, the variables x,y and z are not being saved trough the gps.locate() command. I have set up a satelite with 4 computers and my turtle can easily find its correct position when I type gps locate.

Here is the code:

Spoilerrednet.open("right")
local tArgs = {…}
local xCoord = tArgs[1]
local yCoord = tArgs[2]
local zCoord = tArgs[3]
x = 0
y = 0
z = 0

local function getPos()
gps.locate(5)
end
x,y,z = getPos()

print(x, y, z)

instead of printing out the x,y and z it prints nothing! What did I do wrong? Btw I'm on Minecraft 1.5 and am using Direwolf20 Pack 1.5.2.

Any help would be most apreciated! Thank you!

igel :)/>
amtra5 #2
Posted 11 December 2013 - 03:22 PM
You are not saving the results from gps.locate() in your variable

Try replacing your gps.locate() with


x, y, z = gps.locate()

Also, the print function doesn't work like that. Try this


print(x..":"..y..":"..z)
Anavrins #3
Posted 11 December 2013 - 08:37 PM
Your getPos() doesn't return the value, it would have to be this:

local function getPos()
  return gps.locate(5)
end

Also, the print function doesn't work like that. Try this
The way the print function is written allows you to replace concatenation with commas.
Edited on 11 December 2013 - 07:44 PM
igelbasis #4
Posted 11 December 2013 - 11:15 PM
Hey there,

it worked and I thank you guys very much :)/>

igel