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

Hey guys, How do I add spaces between variables in a connected string?

Started by Hammerhawk, 25 November 2017 - 01:57 AM
Hammerhawk #1
Posted 25 November 2017 - 02:57 AM
Hey guys, I'm fairly new to coding and only understand the very basic fundamentals of using computercraft. I've come across a problem that isn't really a huge deal by itself, but it sill manages to bother me a little.

I'll post an example of my problem here:

So I have two variables.

R = Bill

P = Nye

print(R..""..P)

The outcome here is:

BillNye

is there any way to put a space in between attached strings?

I could just type print("Bill Nye") but what's the fun in that?

Is there a way to solve this problem or a workaround to fix it?

Anyway, sorry to bother you all with my stupid crap, i'm just a scrub tryina learn ;)/>
Dog #2
Posted 25 November 2017 - 03:37 AM
It's actually working as intended. You're providing two quotes next to each other with no space in between, so it's adding what is between the quotes - nothing. If you want a space between R and P then you'll need to put a space within the quotes.
Dave-ee Jones #3
Posted 01 December 2017 - 03:59 AM
Hopefully these examples should help:

local a = "Jack"
local b = "Jill"

print(a.." and "..B)/>
--# Output: Jack and Jill

print("Who went up the hill? "..a)
--# Output: Who went up the hill? Jack

print("And "..b.." came tumbling after.")
--# And Jill came tumbling after.