|
| 24 Jan 2015 04:41 PM |
I want the output to do this
part.Name part.CFrame
I don't want to do print(part.Name) print(tostring(part.CFrame))
How can I use the print function only once, but have it print out the strings on different lines? |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:44 PM |
print([[Stuff More stuff Even more stuff]])
print("Stuff\ More stuff\ Even more stuff")
print("Stuff\nMore stuff\nEven more stuff") |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:46 PM |
print([=[ If you use these things instead of "" or [[]] or '' it will be a literal string fancy right? No need to cancel out any character\/\{}"}"';[']'];few[le ]=]) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Jan 2015 04:47 PM |
print("YAY\nHI");
Don't forget :(( |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:49 PM |
| They aren't already strings, so I can't do anything like putting in them in quotes so backslashes don't work. |
|
|
| Report Abuse |
|
|
| |
|
|
| 24 Jan 2015 04:52 PM |
see if I do this
print("part.Name/ tostring(part.CFrame)"
it will print the words instead of the values I want.
print(part.Name..tostring(part.CFrame))
that's what I got so far, I inserted a space in it but it wasn't good enough for me.
|
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Jan 2015 04:52 PM |
"They aren't already strings, so I can't do anything like putting in them in quotes so backslashes don't work."
What are you trying to print then? |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:52 PM |
You don't cancel out any characters the other way either.
print(" ' \" \{ \} \\") |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:53 PM |
| tostring(Blah) .. "\n" .. tostring(Blah2) |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:54 PM |
If you wanted to print " you would have to do \" to cancel it out
Or do '"'
But what if you wanted to print both [["']]
What if you wanted to print all 3 kinds?
[=[[["']]]=] |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Jan 2015 04:54 PM |
print(part.Name.."\n"..part.CFrame) Lua and many other languages will automatically tostring everything it prints so no need. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Jan 2015 04:54 PM |
| print(part.Name .. "\n" .. tostring(part.CFrame)) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Jan 2015 04:55 PM |
| Lord that wouldn't work because you are trying to concatenate a userdata with a string. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Jan 2015 04:56 PM |
| Really? I would of thought Lua would automatically tostring the other operand of the concatenation operator if one of the two is a string. I guess that's why we have .. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Jan 2015 04:58 PM |
No, that only works with numbers/strings. Print does in-fact, tostring ALL it's arguments but the expression is first evaluated, meaning:
'part.Name.."\n"..part.CFrame' Would be attempting to concatenate a userdata to a string, and it's not automatic because a lot of unexpected and uncontrollable results might take place. But, since print tostring's all it's arguments, you could do:
print(part.Name .. "\n", part.CFrame) |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Jan 2015 04:59 PM |
| Teach me basic arithmetic next! |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2015 04:59 PM |
Thanks.
the .."\n".. works. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 24 Jan 2015 05:04 PM |
"I would of thought Lua would automatically tostring the other operand of the concatenation operator if one of the two is a string."
I'm talking about just the concatenation operator alone, not the print function. That's why I thought your reply was useless. In languages where the addition operator and the concatenation operator are same, I'd expect other results. |
|
|
| Report Abuse |
|
|