Attempt to concatenate global 'q101' (a nil value)
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
Numbers cannot be variables and so do not work that way.
You want to assign the string
"HELLO" to your variable:
q101 = "HELLO".
kevin ver 12 months
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)
kevin ver almost 9 yearsi have one more little question, i'f updated the original question
Etan Reisner almost 9 years
q1is a string
"q201". You then use that in your display call. So you display that string. You want that used as a variable. You need to look it up in the globals table
_G[q1]or use a local table instead of
_Gand do the same sort of lookup.