I am trying to create a quiz game that asks a question then plays a short audio file. I would like to give the user the ability to play the audio file again, but without the speech. How would I do this?
Here is my update that asks the question and plays the file:
action (UpdateGame) {
description (Evaluate user's answer and updates the game state.)
type (UpdateTransaction)
collect {
input (state) {
type (State)
min (Required) max (One)
}
input (fileToPlay) {
description (Create the playlist to play)
type (audioPlayer.AudioInfo)
min (Optional) max (One)
default-init {
intent {
goal: fileAudioInfo
}
}
hidden
}
computed-input (play) {
description (Ask the client to play our sound.)
type (audioPlayer.Result)
compute {
intent {
goal: audioPlayer.PlayAudio
value: $expr(fileToPlay)
}
}
hidden
}
input (answer){
type (Answer)
min (Required) max (One)
default-init {
intent {
goal: ChooseAnswer
}
}
}
}
output (State)
}
My State object looks like this:
structure (State) {
description (Holds the game state.)
features {
transaction
transient
}
property (game) {
type (Game)
min (Required) max (One)
visibility (Private)
}
property (currentQuestion) {
type (Question)
min (Required) max (One)
visibility (Private)
}
property (restartQuestion){
type (RestartQuestion)
min (Required) max (Many)
visibility (Private)
}
property (completed) {
type (core.Boolean)
min (Optional) max (One)
visibility (Private)
}
property (change) {
type (core.Boolean)
min (Optional) max (One)
visibility (Private)
}
property (say) {
type (core.Text)
min (Optional) max (One)
description(Should the introductory be read or not?)
}
property (display) {
type (core.Text)
min (Required) max (One)
description(Should the introductory be read or not?)
visibility (Private)
}
}
I have a ReplayAudio action that looks as follows:
action (ReplayAudio) {
description (__DESCRIPTION__)
type (UpdateTransaction)
collect {
input (state) {
type (State)
min (Required) max (One)
default-init {
intent {
goal: ReplayAudio
}
}
validate {
replan{
intent{
goal: UpdateGame
value: State {
currentQuestion: $expr(state.currentQuestion)
display: $expr(state.display)
game: $expr(state.game)
restartQuestion: $expr(state.restartQuestion)
}
}
}
}
}
}
output (State)
}
So I am trying to omit the say
field. The issue is, that when I set the say field again in UpdateGame
it stays blank and I can never reset it.
Why would removing the say
field, cause it to never be updated again?
I would think you can reassign the value of say
to " " (empty string with only a space), that would be equivalent as no speech.