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

There a way I can contribute on the wiki? GPS tutorial needs updating

Started by FredMastro, 10 March 2014 - 01:25 PM
FredMastro #1
Posted 10 March 2014 - 02:25 PM
Being new to ComputerCraft I'm going through the tutorials and will probably find issues with outdated code.

Example on the GPI API's tutorial page for Vectors it has this:


print("I am ", displacement.tostring(), " away from home!!!")

Which doesn't work. Through trial and error and going through form posts I found it works like this:


print("I am "..tostring(displacement).." away from home!!!")

I was going to update the wiki but doesn't seem I have access too. I think someone should update it though. Would have saved me research time.
Lyqyd #2
Posted 10 March 2014 - 02:34 PM
Moved to Wiki Discussion.
Cranium #3
Posted 10 March 2014 - 05:40 PM
And corrected for you. We should have people adding editors to the wiki, but I haven't been in the loop for a while.
theoriginalbit #4
Posted 11 March 2014 - 12:09 AM
I found it works like this:

print("I am "..tostring(displacement).." away from home!!!")
Cranium has already updated the wiki to an adaption of your code, but to just expand on what the problem actually was. It was because they used displacement.tostring instead of displacement:tostring since the Vector API was implemented correctly however it does implement the __tostring metamethod, meaning the 3 ways you can invoke it are as follows:

print("I am ", displacement.tostring(displacement), " away from home!!!") --# you must pass the reference to itself when using dot notation
print("I am ", displacement:tostring(), " away from home!!!") --# colon syntax makes the above easier as it automatically passes the reference
print("I am ", tostring(displacement), " away from home!!!")
basically what I'm saying here is with the print function you can pass it multiple arguments and they'll be concatenated, you don't need to concat them to print.