> So in this project which would be the current loop that we are seeing the loop index for?
loopindex always refers to the currently running loop. For example, in this "for" loop:
For "i" from 0 to 3, append text loopindex to TextObject.
the text displayed by TextObject would be "0123"; each time the loop runs it takes the current loopindex value (which steps up by 1 with each loop from 0 to 3) and adds it to the text string.
The index tag allows you to differentiate between loopindices in nested loops e.g.
For "i" from 1 to 2
--For "j" from 1 to 3, append loopindex("i") * loopindex("j") to TextObject
...would display "123246" - during this nested loop each step of "i" runs a complete loop from 1 to 3 of "j".
> Also what does + Answers: no = LoopIndex("DrawAnswers") mean?
> I know we drew the answers from the array, but now what is that code used for. What are the instance variables correct and no used for?
txt_answers.no is an instance variable that distinguishes between the different instances of txt_answers - if you check the txt_answers objects in the layout you will see the value of "no" increases by one for each object as you go down the layout.
txt_answers.correct is an instance variable that equals 1 if the answer it is displaying has been marked in the questions array as a correct answer (check the "Depth = 1" sheet in the array editor for a_questions: correct answers are marked with a 1, incorrect with a 0).
Event 6 runs a loop through each of the answers in a_questions for the current question; if the current answer slot in the array isn't blank it picks the txt_answer object with a "no" value that corresponds to the current answer (loopindex "i"), then sets the text of that txt_answer object to the answer (using the shuffled permutation table, if the action specifies it).
In Event 7 (function checkQuestion) each txt_answer is checked to see if it has been selected by the user (txt_answer.selected is true) and if it is a correct answer (txt_answer.correct is 1); if both are true or both are false spr_tickCross displays a tick, otherwise a cross is shown.
Thanks! How can I do it so that when you press the corre ct answer it adds one to the Corret variable.(new one tat i made) and when its wrong subtract 1
+ Answers: correct = 0
----+ Answers: Is selected
----+ System: Trigger once
-----> System: Add 1 to Correct
----+ Answers: [X] Is selected
----+ System: Trigger once
-----> System: Subtract 1 from Correct