--LINGO SCRIPT illustrating use of "Lists", random function, and timer.
-- Make 2 text castmembers called "answer" and "question".
-- Attach this script to a button that makes the "question" text appear and that triggers the timer.
-- After a few seconds the timer triggers a flag that enables the "answer" text to appear.
property questionList, answerlist, timerFlag
on beginSprite me
questionList = ["What are you doing here?", "What makes you want to be here?", "How long will you be here?"]
answerlist = ["I am learning how to measure electrical fields near Mt. Tom.", "There is a very special Walmart in this area where I love to shop.", "I have been sent to help organize anti-war efforts."]
timerFlag = 0
end
on mouseUp me
-- if the list has emptied (total count is 0) then get it filled back up.
if questionList.count < 1 then
questionList = ["What are you doing here?", "What makes you want to be here?", "How long will you be here?"]
end if
a = random(questionList.count)
member("question").text = questionList[a]
questionList.deleteAt(a)
timerFlag = 1
startTimer
end
on exitFrame me
if timerFlag = 1 then
if the timer > random(4) * 60 then
timeToAnswer
timerFlag = 0
end if
end if
end
on timeToAnswer me
-- if the list has emptied (total count is 0) then get it filled back up.
if answerList.count < 1 then
answerList = ["I am learning how to measure electrical fields near Mt. Tom.", "There is a very special Walmart in this area where I love to shop.", "I have been sent to help organize anti-war efforts."]
end if
x = random(answerList.count)
member("answer").text = answerList[x]
answerList.deleteAt(x)
end
on endSprite me
-- when this sprite is finished get the text cast members to be empty again.
member("question").text = ""
member("answer").text = ""
end