Hi guys, im having some problems trying to concatenate some stuff and it’ll help me a lot reducing my current code.
Lets say i have this:
local image1 = display.newImage("image1.png") local image2 = display.newImage("image2.png") local image3 = display.newImage("image3.png") local equip = 1 image1.isVisible = false image2.isVisible = false image3.isVisible = false
and then somewhere else in the code i want to check “equip” value and show that image.
if equip == 1 then "image"..equip.isVisible = true "image"..equip.x = 200 "image"..equip.y = 300 end
I know this isn’t working, and i’ve tried other methods but all of them give me errors. I know this might be a little bit basic by this time but i don’t know how to resolve this.
I’ve tried
local conc = "image"..equip if equip == 1 then conc.isVisible = true end
but it gives me an error because conc is a string, isnt there a way to transform that string into data? i just want to use the variable reference
Thanks in advance.