Question Overlay (V4) [NOT REQUIRED]
Questions + Answers for API V4

Note: only developers who are instructed by the LoL staff to use this feature are permitted. Otherwise this feature is discouraged from use in all instructional games.

Show a Question

The ShowQuestion method instructs the LOL Platform to display an overlay with a question from the LOL question bank. Game play is cannot continue until the answer result is received and the overlay is dismissed.

Receive the Answer Result

Register an event delegate or listener to handle the AnswerResultReceived event. This event indicates that the question overlay has been dismissed so that game play can continue.
The AnswerResultReceived payload contains a single JSON key value pair indicating whether or not the question was answered correctly, or if the overlay was dismissed without an answer.
1
{ "isCorrect": "true" } // The answer was correct
2
{ "isCorrect": "false" } // The answer was incorrect
3
{ "isCorrect": null } // The overlay was dismissed with no answer
Copied!

Code Examples

Javascript interface

1
// Show Question (trigger overlay)
2
window.postMessage({messageName: 'showQuestion', payload: '{}'}, '*');
3
4
// Receive Result (receive response)
5
window.addEventListener("message", function (msg) {
6
// Message name and JSONified payload
7
const { message, payload } = msg.data;
8
if (message === 'answerResult') {
9
// do something with payload.isCorrect (true or false or null)
10
}
11
}
Copied!

Unity interface

1
// Triggering the Show Question overlay (assuming LOLSDK is setup, see docs)
2
LOLSDK.Instance.ShowQuestion();
3
4
// Receiving
5
6
// Register an event delegate
7
LOLSDK.Instance.AnswerResultReceived += new AnswerResultReceivedHandler (this.HandleAnswerResult);
8
9
// Do something with the result
10
private void HandleAnswerResult(string json) {
11
JSONNode answerResult = JSON.Parse(json);
12
var isCorrect = answerResult["isCorrect"];
13
14
switch (isCorrect) {
15
case "true":
16
answerResultText.text = "correct";
17
break;
18
case "false":
19
answerResultText.text = "incorrect";
20
break;
21
default:
22
answerResultText.text = "no answer";
23
break;
24
}
25
}
Copied!
Last modified 3mo ago