Reputation: 11
Some context, This is some of my first programming in Lua and I am doing it with QSC software.
local a = Controls.Flippy.String
local b = Controls.Flippy.Value
local c = Controls.Flippy.Position
local d = " "
print(a..d..b..d..c)
This worked but is there away I can write strings in line with a variables. Such as:
print("controls "a" "b" "c)
Upvotes: 1
Views: 5844
Reputation: 28950
There are several ways to print multiple values in a line.
local name = "Frank"
local age = 15
-- simple, but not applicable for my example due to formatting:
print("My name is", name, "I'm", age, "years old")
-- using the concatenation operator ..
print("My name is " .. name .. ". I'm " .. age .. " years old")
-- using string.format, best for complex expressions, capable of advanced formatting
print(string.format("My name is %s. I'm %d years old.", name, age))
Upvotes: 1
Reputation: 36
You can just write the strings as
print("controls", a, b, c)
You can choose not to put spaces in between if you wish not to.
Hope that helps!
Upvotes: 2
Reputation: 714
Same way you put the strings together--with ..
, the concatenation operator.
print("controls "..a.." "..b.." "..c)
It is also possible to use print with multiple arguments, though the spacing is often different (which may or may not be desirable):
print("controls",a,b,c)
Upvotes: 3