generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Print multiple lines without using print multiple times?

Previous Thread :: Next Thread 
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jan 2015 04:47 PM
print("YAY\nHI");

Don't forget :((
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
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
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
24 Jan 2015 04:51 PM
Then do \n
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
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 is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
24 Jan 2015 04:52 PM
You don't cancel out any characters the other way either.

print(" ' \" \{ \} \\")
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
24 Jan 2015 04:53 PM
tostring(Blah) .. "\n" .. tostring(Blah2)
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jan 2015 04:54 PM
print(part.Name .. "\n" .. tostring(part.CFrame))
Report Abuse
cntkillme is not online. 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 is not online. 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 is not online. 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 is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
24 Jan 2015 04:59 PM
Teach me basic arithmetic next!
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
24 Jan 2015 04:59 PM
Thanks.

the .."\n".. works.
Report Abuse
lordrambo is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image