quizHelper.lua utility file - VanaDev/Vana GitHub Wiki

Table of Contents

quizHelper.lua

Category: Utility Lua-Based Scripts

answer_incorrect

Type: number

Notes: Used as a return value from the askQuizQuestion function to indicate the player has answered incorrectly.

answer_correct

Type: number

Notes: Used as a return value from the askQuizQuestion function to indicate the player has answered correctly.

makeQuizQuestion

Return(s):

  • quizQuestion: table
Argument(s):
  • question: string
  • correctAnswerIndex: number
  • answers: table
Notes: Synthesizes question data into a format understood by askQuizQuestion.

Usage:

 makeQuizQuestion("Which of these items does the Flaming Raccoon NOT drop?", 2, {"Raccoon Firewood ", "Solid Horn ", "Red Brick "}),

askQuizQuestion

Return(s):

  • answerResultCode: number
Argument(s):
  • questions: array table
  • Optional - prefix: string
Notes: Selects a random question that hasn't been previously asked of the player and adds the specified prefix text before the question.

Usage:

 for i = 1, 5 do
 	if askQuizQuestion(questions, "Question no." .. i .. ": ") == answer_incorrect then
 		addText("Hmmm...all humans make mistakes anyway! ");
 		sendNext();
 		return;
 	end
 end
⚠️ **GitHub.com Fallback** ⚠️