Jump to content

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

3 replies to this topic

#1 FredMastro

  • Members
  • 5 posts

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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,459 posts

Posted 10 March 2014 - 02:34 PM

Moved to Wiki Discussion.

#3 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

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.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 11 March 2014 - 12:09 AM

View PostFredMastro, on 10 March 2014 - 02:25 PM, said:

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.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users