Reputation: 13
In python you are able to print 2 things by using one statement by typing
print("Hello" + " World")
Output would be "Hello world"
So is there a simple to do this again in Lua?
I'm trying to make the statement print the percentage and the percentage sign. This is currently what I have
function update()
local hp = crysHu.Health/ crysHu.MaxHealth
local text = script.Parent.TextLabel
healthBar:TweenSize(UDim2.new(hp,0,1,0),"In","Linear",1)
text.Text = math.floor(hp*100)
end
text.Text = math.floor(hp*100)
is the part that I need help with FYI.
doing text.Text = (math.floor(hp*100) + "%"
) doesn't work.
Upvotes: 1
Views: 1507
Reputation: 7188
If you're doing simple string manipulations, you can concatenate them with ..
like this :
local foo = 100
print( tostring(foo) .. "%") -- 100%
or if you want more specific formatting you can use string.format
local foo = 100
print( string.format("%d%%", foo)) -- 100%
Upvotes: 4
Reputation: 7889
Use a ,
. Its the same for both Lua and Python though Lua puts a tab between them in a print
:
print(2, 3) # 2 3
or use io.write
but then you need to handle the newline.
io.write("hello", " world\n") # hello world
Upvotes: 0