I need to change the following code, so it will only display a maximum number of correct objects (only 1 correct object should display every time, the rest should be “wrong”)… Right now it will display more than the max… of 1. Any suggestions? Thank you.
for i = 1, #colorTable do if colorTable[i] ~= correctColor then wrongColorTable[#wrongColorTable+1] = colorTable[i] end end for objectNum = 1, totalObjects do local object if not((totalCorrectObjects == maxCorrectObjects) and totalObjects-objectNum == minCorrectObjects) then --if there's the minimum amount of correct objects if math.random(1,2) == 1 then --correct object object = display.newImageRect(correctColor[math.random(2, #correctColor)],205,155) totalCorrectObjects = totalCorrectObjects+1 --a correct object has been added object.name = "correct" else --wrong object local randomIndex = math.random(1, #wrongColorTable) object = display.newImageRect(wrongColorTable[math.random(1, #wrongColorTable)][math.random(2, #wrongColorTable[randomIndex])],205,155) object.name = "wrong" end else --display a correct object object = display.newImageRect(correctColor[math.random(2, #correctColor)],205,155) totalCorrectObjects = totalCorrectObjects+1 --a correct object has been added object.name = "correct" end