问题
i like to load text form a external .lua file in to my game, here is a little test i setup to test the principal, i know if i give "q101" numbers like so "q101 = 123456" the code displays the numbers 123456 but i don't understand why it doesn't with letters.
Can some one please explain how i can do this is the right way, as this is clearly not the way of doing it
q101 = HELLO
Q1 = display.newText("".. q101, 160, 20, MYRIADPRO, 30)
Q1:setTextColor( 255, 255, 2552)
Q1.x = display.contentWidth/2
Q1.y = display.contentHeight/2
screenGroup:insert(Q1)
回答1:
This line q101 = HELLO
is setting the value of the q101
variable to the value of the HELLO
variable. And as the global variable with that name has no value (as it has never been defined) you are assigning nil
to your q101
variable.
Numbers cannot be variables and so do not work that way.
You want to assign the string "HELLO"
to your variable: q101 = "HELLO"
.
来源:https://stackoverflow.com/questions/24493566/attempt-to-concatenate-global-q101-a-nil-value