With the following code I think that I have created it: I have a counter that shows the content one by one and when I get to the last content of the array it becomes 0 and therefore I return to the beginning but I do not get it, I get the error IndexError: list index out of range.
Code: Select all
define myarray = ["A", "B", "C"]
define counter = 0
screen test_array:
imagebutton idle "button.png" action SetVariable("counter", counter + 1)
if counter == len(myarray):
$ counter = 0
text myarray[counter]
- With if counter == len(myarray) it loop and shows "A" but next appears IndexError: list index out of range
- With if counter >= len(myarray) it loop and shows "A" but then it stagnates and stays in "A" no matter how much I press the button
- With if counter <= len(myarray) I press the botton but only appears "A" but on the 4th botton press it appears IndexError: list index out of range