• /n - Need help with newline :S
    20 replies, posted
Hello, I cant get the /n command to work, hel me ! Code: [lua] local CinemaINFO = vgui.Create( "DLabel" ) CinemaINFO:SetText( "This is the In-Game Source Recorder"..\n"me likes icecream" ) CinemaINFO:SetParent( CinemaRecorder ) CinemaINFO:SetPos( 5, 20 ) CinemaINFO:SetTextColor( Color(188, 247, 53, 255) ) CinemaINFO:SizeToContents( ) [/lua]
You don't need to concatenate the newline character with the text, it is an escape character. [lua]CinemaINFO:SetText( "This is the In-Game Source Recorder\nme likes icecream" )[/lua]
[QUOTE=NullPoint;19919422]You don't need to concatenate the newline character with the text, it is an escape character. [lua]CinemaINFO:SetText( "This is the In-Game Source Recorder\nme likes icecream" )[/lua][/QUOTE] Thank you sir ! The mystery is finnaly over :S
Also, remember it's \n not /n (as you wrote it in the title).
You can do it like this to make it more visually appealing. [lua] print( "Because they don't rhyme\n".. "Haikus don't really make sense\n".. "Why did I write that?" ); [/lua]
[lua] print( "They're happy\n".. "Because they eat\n".. "LARD" ); [/lua] :downs:
semicolons are not visually appealing
;)
[QUOTE=yakahughes;19928528]semicolons are not visually appealing[/QUOTE]If you actually program it is visually appealing
[QUOTE=cheesylard;19948877]If you actually program it is [b]usually necessary[/b][/QUOTE] Fix'd
[QUOTE=Gbps;19950001]Fix'd[/QUOTE] yeah
[QUOTE=cheesylard;19928027]You can do it like this to make it more visually appealing. [lua]print( "Because they don't rhyme\n".. "Haikus don't really make sense\n".. "Why did I write that?" );[/lua] [/QUOTE] Here's a little secret. If you use the [[string]] way then you can type text in literally. [lua]print[[Haikus are great but sometimes they don't make sense refrigerator]][/lua]
Technically, [[ and ]] will escape all characters within the string.
[QUOTE=fishface60;19964105]Here's a little secret. If you use the [[string]] way then you can type text in literally. [lua]print([[Haikus are great but sometimes they don't make sense refrigerator]])[/lua][/QUOTE] Fix'd.
You didn't fix anything. You don't need parenthesis when calling single argument functions in Lua, though often grounded upon for it's lack of organization depending on the reader. [editline]11:44PM[/editline] Grounded = frowned iPhone :l
Oh really, I had no idea. Thanks for telling me that.
[QUOTE=Gbps;19970865]You didn't fix anything. You don't need parenthesis when calling single argument functions in Lua, though often grounded upon for it's lack of organization depending on the reader.[/QUOTE] You can only drop the parentheses when the first and only argument to the function is a string (or table).
[QUOTE=NullPoint;19972461]You can only drop the parentheses when the first and only argument to the function is a string.[/QUOTE] Incorrect, it can be any form of string or a table. The table use is handy if there are lots of optional configuration options in a function. Instead of having lots of parameters which you might leave as nil sending a table as the only parameter.
[QUOTE=fishface60;19982623]Incorrect, it can be any form of string or a table. The table use is handy if there are lots of optional configuration options in a function. Instead of having lots of parameters which you might leave as nil sending a table as the only parameter.[/QUOTE] Ineed, I completely forgot about tables.
[QUOTE=fishface60;19964105]Here's a little secret. If you use the [[string]] way then you can type text in literally. [lua]print[[Haikus are great but sometimes they don't make sense refrigerator]][/lua][/QUOTE] Woah, I've never seen that before. Is it only in Lua or is it available in other programming languages?
[QUOTE=cheesylard;20035426]Woah, I've never seen that before. Is it only in Lua or is it available in other programming languages?[/QUOTE] [[ and ]] are a feature of Lua. Python has something similar which is """ and """. Ruby's strings are multiline automagically, so they act like [[ and ]], however you do have to escape " or ', depending on what you used. Ruby also has this %[ and ], %{ and }, and %( and ).
Sorry, you need to Log In to post a reply to this thread.