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

attempt to concatenate string and nil

Started by zachtownes, 06 December 2013 - 10:29 PM
zachtownes #1
Posted 06 December 2013 - 11:29 PM
I have a problem with my api when I go to use a few functions…

here is the api. http://pastebin.com/zYeRnCZb

the problem is when I use the startLoc() function and then the getLoc() function and I try to print the facing variable to the screen it gives me the attempt to concatenate string and nil error.

Here is and example of a basic program using those function and where I get the error.

t.getLoc()
print("I am here"..x..","..y..","..z..". Facing"..facing)
t.tl()
t.getLoc()
print("I am now facing"..facing)
t.tl()
t.getLoc()
print("I am now facing"..facing)
t.tl()
t.getLoc()
print("I am now facing"..facing)
t.tle()
t.getLoc()
print("I am now facing"..facing)

The error happens
test:2: attempt to concatenate string and nil

thanks for any help
distantcam #2
Posted 06 December 2013 - 11:38 PM
You need to assign the values from getLoc to the variables x, y, z and facing.

x, y, z, facing = t.getLoc()
zachtownes #3
Posted 06 December 2013 - 11:49 PM
Is this in the program or the api?

Oh, Nevermind. I tried both….Its the program…Thanks for the help. I really appreciate it!