So here’s a repost of my last post. It was pointed out that my adding comments in the lua section made it hard to read.
So it’s a flashcard app where currentCard is the current card the user sees on screen and questionsAndAnswers is the table of questions and answers (ingenious I know haha). The following code is for my questionsAnsdAnswers table and for when they click to go onto the NEXT card. Also “text” is a native textbox.
My questionsAndAnswers table
[lua]
local questionsAndAnswers = {
{Q = “Question 1: What is 1 + 2?”, A = “Answer 1: equals 3”, location = nil},
{Q = “Question 2: What is 2 + 2?”, A = “Answer 2: equals 4”}
}
[/lua]
Next function
[lua]
print ("this is currentCard: "…currentCard)
print ("this is current text.text: "…text.text)
if (currentCard+1 <= #questionsAndAnswers) then
currentCard = currentCard+1
print ("1This is current card now "…currentCard)
print (questionsAndAnswers[currentCard].Q)
–text.text = questionsAndAnswers[currentCard].Q
text.text = (questionsAndAnswers[currentCard].Q)
–markedStatusText.text = “”
print ("this is text.text "…text.text)
print ("printing statement1: "… text.text)
if (marked[tonumber(string.match (string.sub( text.text, 8 , 13 ), “%d+”))] == true) then
for k, v in pairs( marked ) do
print(k, v)
end
markedStatusText.text = “Marked”
print (“making markedStatusText say marked”)
else
print (“making markedStatusText become nil”)
markedStatusText.text = “”
end
[/lua]
And here’s terminal readings
[lua]
this is currentCard: 1
this is current text.text: Question 1: What is 1 + 2?
1This is current card now 2
Question 2: What is 2 + 2 --*** This is what I want text.text to be
This is text.text Question 1: What is 1 + 2?
printing statement1: Question 1: What is 1 + 2?
making markedStatusText become nil
[/lua]
So up above in the terminal output I put in a comment with “***”. That is what I want to have text.text show but even when I code the next line, as “text.text = (questionsAndAnswers[currentCard].Q)” I can’t get the correct text to appear
Any ideas are welcome! I even tried to put "text.text == questionsAndAnswers[currentCard].Q " But then corona simulator doesn’t start up saying that it expects “=” where “==” is
Thanks!