I have an array that looks like this:
local difficultyLevel = true if difficultyLevel then local imagePaths = { {imgValue="image/easy/pic1.png",theWeight=9}, {imgValue="image/easy/pic2.png",theWeight=2} } else local imagePaths = { {imgValue="image/hard/pic1.png",theWeight=9}, {imgValue="image/hard/pic2.png",theWeight=2} } end
This works fine. No problems with loading the correct image when I need it. Now instead I want to use a variable within the array to reduce lines of code. For example:
local difficultyLevel = true if difficultyLevel then local level = "easy" else local level = "hard" end local imagePaths = { {imgValue="image/"..level.."/pic1.png",theWeight=9}, {imgValue="image/"..level.."/pic2.png",theWeight=2} }
This fails horribly. It as if I can’t use concatenation within the defining of the parts of the array. Is this not possible to do?