backIndex

Xelagot action script

Events: Trivia

Refer to Events for general information about events, and to Topics: Trivia for information about trivia.

This page has two sections: trivia events and trivia statements

Trivia events

Installers:

OnTriviaLoadedEvent <eventlabel>
Event type: 20001
is triggered when a trivia question file has finished loading

OnTriviaGameStartingEvent <eventlabel>
Event type: 20006
is triggered just before a trivia game is started, i.e. before the bot announces it

OnTriviaGameStartedEvent <eventlabel>
Event type: 20007
is triggered as soon as a trivia game has started

OnTriviaQuestionAskingEvent <eventlabel>
Event type: 20002
is triggered just before a question is asked

OnTriviaQuestionAskedEvent <eventlabel>
Event type: 20003
is triggered as soon as a question has been asked

OnTriviaQuestionClosingEvent <eventlabel>
Event type: 20004
is triggered just before a question is closed (no more answers allowed, but before the score is annouced)

OnTriviaQuestionClosedEvent <eventlabel>
Event type: 20005
is triggered when a question is closed (no more answers allowed, score has been annouced)

OnTriviaGameEndingEvent <eventlabel>
Event type: 20008
is triggered at the end of the game before the winner is announced, once for each winner (in the case of a draw, it will be triggered more than once)

OnTriviaGameEndedEvent <eventlabel>
Event type: 20009
is triggered at the end of the game after the winner is announced, once for each winner (in the case of a draw, it will be triggered more than once)

You do not need to install all events, of course. You may wish to install the ...ing events (e.g. OnQuestionClosingEvent) instead of the ...ed events (e.g. OnQuestionClosedEvent): they carry the same information but are triggered just before something happens instead of after, and some of them allow you to manipulate what will happen.

Specific statements (must be inside the event handler):

GetEventType %a stores the event type code in variable %a
GetEventResult %a stores the event result code in variable %a. 0 means success, other positive codes are equivalent to the rc codes of the SDK and the Windows codes. See SDK Error Codes.

 

Trivia statements

IfTriviaLoad $f statement1
Else statement2
attempts to load a trivia question file or a trivia ini file, specified in $f. The 'Else' line is optional. If the filename ends in .txt it will be treated as a question file, if it ends in .ini it will be treated as an ini file.

Notes:
A successful attempt to load a question file only starts the loading process, it triggers a OnTriviaLoadedEvent when the file is loaded (and shuffled). Ini files are loaded inmediately, they do not trigger an event.
Trivia question files may only be loaded when a game is stopped, ini files may be loaded at all times.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames.

xelagot 3.606 or older
The file $f should be in the same folder as the script if no path is included (this is the recommended way).
IfTriviaIsStopped statement1
Else statement2

IfTriviaIsNotStopped statement1
Else statement2


IfTriviaIsPlaying statement1
Else statement2

IfTriviaIsNotPlaying statement1
Else statement2


IfTriviaIsPlayingWFS statement1
Else statement2

IfTriviaIsNotSPlayingWFS statement1
Else statement2


IfTriviaIsPaused statement1
Else statement2

IfTriviaIsNotPaused statement1
Else statement2


IfTriviaIsWaiting statement1
Else statement2

IfTriviaIsNotWaiting statement1
Else statement2


checks the status of trivia. There are 5 states: stopped, playing, playingWFS (playing but waiting for server), paused, waiting (a new game is coming). If the condition is met, statement1 is executed, otherwise statement2 in the Else line is executed. The Else line is optional, you can omit it if you don't need it.
TriviaStart
TriviaPause
TriviaStop
Start (or resume), pause or stop (cancel) a trivia game.
TriviaShuffle
TriviaUnShuffle
Shuffle or 'un'-shuffle the questions. Unshuffled questions are said in the same order as in the original file. When a trivia question file is loaded, it is shuffled by default.
TriviaQuestionsCount %q Retrieves in %q the total number of questions available
TriviaSetQuestionIndex %q Sets the current question index to %q. Offset is 1.

Note: if the questions are not shuffled, setting the current question index follows the order of the questions in the file; if the file is shuffled, you never know what this statement does.
TriviaGetQOFQ %q %r Retrieves in %q and %r the values of '%q questions asked of %r questions in this game'

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
OnTriviaGameEndingEvent
OnTriviaGameEndedEvent
TriviaGetScore %s Retrieves in %s the score of the current participant. If it is = 0, there is no current participant. In an OnTriviaQuestionClosingEvent or OnTriviaQuestionClosedEvent, the current participant is the person who answered correctly. In an OnTriviaGameEndingEvent or OnTriviaGameEndedEvent this is the winner (there may be more than one winner, or none). This current participant (good answerer or winner) can be retrieved in a person variable with GetChatPerson &p if the score is larger than 0.
Note that in the OnTriviaQuestionClosingEvent, the score can be changed by the script using TriviaSetScore %s.

Applies to:
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
OnTriviaGameEndingEvent
OnTriviaGameEndedEvent
TriviaWinnersCount %n Retrieves in %n the number of winners in a OnTriviaGameEndedEvent. If it is = 0, nobody won (there were no good answers). If it is = 1, there is one winner (the most common case). If it is > 1, there is a draw between %n contestants, and there will be %n number of OnTriviaGameEndedEvent, each with its own data about the winner.

Applies to:
OnTriviaGameEndedEvent
TriviaGetWinnerNumber %w Retrieves in %n the number of the current winner in an OnTriviaGameEndingEvent or OnTriviaGameEndedEvent. If it is = 0, nobody won (there were no good answers), and you can not retrieve the data of the winner. In all other cases, it will indicate which of the winners it is. If the number of winners (see TriviaWinners %n) is larger than one, this number %w will be between 1 and the number of winners %n, as there will be %n number of OnTriviaGameEndingEvent and OnTriviaGameEndedEvent, each with its own data about the winner.

Applies to:
OnTriviaGameEndingEvent
OnTriviaGameEndedEvent
GetChatPerson &p Retrieves in &p the data of the current participant, if the score retrieved with TriviaScore %s is larger than 0 (if it is = 0, then there was no good answer so GetChatPerson is useless). In an OnTriviaQuestionClosedEvent, the current participant is the person who answered correctly. In an OnTriviaGameEndedEvent this is the winner (there may be more than one winner; or none if TriviaWinners retrieves 0).

Applies to:
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
OnTriviaGameEndingEvent
OnTriviaGameEndedEvent
TriviaGetNextGameVRT !t
TriviaGetNextGameLocal !t
Gets the date and time (in VRT or Local Time) of the next game and stores it in !t... but you must always test IF there is a next game:
IfTriviaIsWaiting TriviaGetNextGameVRT !t
Else
...
If you do not test this, you may get a weird date in the past!
TriviaSetNextGameVRT !t
TriviaSetNextGameLocal !t
Sets the date and time of the next game in VRT or Local Time. This can not be done while the bot is playing a game, trivia status must be either stopped, waiting or paused (if it is paused, this statement sets the time when the game will continue). If the bot has a trivia game going, this statement is ignored.
TriviaBlockAnswers Makes the bot ignore all trivia answers. The script has to send a TriviaGoodAnswer &p or TriviaNoAnswer to close the question (or let the timeout occur).

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
TriviaGoodAnswer &p Closes the question, giving &p the scores. It is intended to be used after a TriviaBlockAnswers statement.
TriviaNoAnswer Closes the question, as if no one had answered correctly, before timeout occurs.
TriviaGetSeparator $s version 3.427
Gets the separator used in the file to separate question from answers etc, also used in the question to mark a line break.

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaGetCategory $c version 3.427
Gets the category of the question

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaGetQuestion $q Gets the full text of the question

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaGetAnswer $a Gets the full text of the first answer

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaGetAnswers /s_List version 3.427
Gets in a string list all the answers

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaGetMsg $m Gets the tag or message attached to the question in Xelagot Question files

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaClearPlayers Normally, all people can play, including Tourists and Bots if they are allowed to play. But a list of Players can be created to limit participation to the ones on the list (this list overrides the banning of Tourists and Bots). If the list is cleared, everyone allowed can play. The list is cleared by default when a game starts, just before the OnTriviaGameStartingEvent.

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
and any moment during the game until the last question is closed.
TriviaAddPlayer &p
TriviaAddPlayer $name
Adds the name of a player to the Players list. If the Players list has names, participation is limited to those named players. Tourists and Bots can be added to the list even when they are banned when all can play (when the Players list is empty). The best moment to add players is in OnTriviaGameStartingEvent or OnTriviaGameStartedEvent.

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
and any moment during the game until the last question is closed.
TriviaAddPlayers /s_MyList
Adds all players names in /s_MyList to the Players list, there must be one player name per string in /s_MyList and only the name. If the Players list has names, participation is limited to those named players. Tourists and Bots can be added to the list even when they are banned when all can play (when the Players list is empty). The best moment to add players is in OnGameTriviaStartingEvent or OnTriviaGameStartedEvent.

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
and any moment during the game until the last question is closed.
TriviaAllowWhisper ON|OFF
version 3.427
Normally, one may not whisper a trivia answer to the bot, the trivia engine simply ignores whispers and whispering answers is set to OFF by default when a game starts. On some occasions, e.g. when there is only one player, one may want to allow answers to be whispered. This statement achieves this.

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
and any moment during the game until the last question is closed.
TriviaPlayersCount %c Retrieves the number of players on the Players list. If it is 0, anyone allowed to play may play, otherwise only the names on the list may play.

Applies to:
OnTriviaGameStartingEvent
OnTriviaGameStartedEvent
and any moment during the game until the last question is closed.
TriviaSetScore %s Normally, the score is calculated by the Trivia engine automatically. But the script can change that in the event OnTriviaQuestionClosingEvent. The value passed must be 1 or more, setting it lower than 1 enables automatic score calculation. Automatic score calculation is enabled when a question is asked.

Applies to:
OnTriviaQuestionClosingEvent
TriviaSetThisTimeout %s Changes the timeout of an individual question (in seconds) if issued in OnTriviaQuestionAskingEvent or OnTriviaQuestionAskedEvent, and the timeout between question if issued OnTriviaQuestionClosingEvent or OnTriviaQuestionClosedEvent.

Applies to:
OnTriviaQuestionAskingEvent
OnTriviaQuestionAskedEvent
OnTriviaQuestionClosingEvent
OnTriviaQuestionClosedEvent
TriviaKillAnnounce If you wish to stop the bot from announcing during Trivia, you must install the corresponding ...ingEvent handlers, i.e. those that are triggered just before the bot announces something. In each of those event handlers, you can stop the bot from speaking the pending text with TriviaKillAnnounce, and substitute this text with your own using SayConcat for example.

Applies to:
OnTriviaGameStartingEvent
OnTriviaQuestionAskingEvent
OnTriviaQuestionClosingEvent
OnTriviaGameEndingEvent
TriviaGetQuestionsPerGame %r
TriviaSetQuestionsPerGame %r
Retrieves or sets the number of questions per game. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
TriviaGetQuestionTimeout %s
TriviaSetQuestionTimeout %s
Retrieves or sets the number of seconds the bot waits for answers to a Trivia question. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
TriviaGetMaxPointsPerQuestion %m
TriviaSetMaxPointsPerQuestion %m
Retrieves or sets the maximum points awarded for a correct answer to a Trivia question. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
TriviaGetPauseBetweenQuestions %q
TriviaSetPauseBetweenQuestions %q
Retrieves or sets the number of seconds the bot waits between questions. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
TriviaGetPauseBetweenGames %g
TriviaSetPauseBetweenGames %g
Retrieves or sets the number of minutes the bot waits between games. If set to 0, only one game is played. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
IfTriviaAllowsBotsToPlay statement1
Else statement2
Tests if bots are allowed to play, if yes then statement1 is executed, otherwise an optional statement2. This is only valid if the Players list is empty. This is one of the Trivia ini file parameters.
TriviaAllowBotsToPlay ON|OFF Allows or disallows bots to play. A bot may always play if it's name is added to the Player's list. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.
IfTriviaAllowsTouristToPlay statement1
Else statement2
Tests if tourists are allowed to play, if yes then statement1 is executed, otherwise an optional statement2. This is only valid if the Players list is empty. This is one of the Trivia ini file parameters.
TriviaAllowTouristsToPlay ON|OFF Allows or disallows tourists to play. A tourist may always play if it's name is added to the Player's list. This is one of the Trivia ini file parameters. Setting this parameter affects the next games, changes done during a game do not affect it.


backIndex