DevJoy.Scene.Choice (DevJoy v2.0.0)
View SourceChoices are visually presented as buttons that allow the user to perform an action. They can be used as simple menu items, as answers to character questions or as a possible condition choice. For example, the action of the chosen option can be used to navigate to other parts or scenes.
Condition
The choice with an atom content
in condition
defmodule MyApp.SceneName do
use DevJoy.Scene
part :condition do
condition :john_doe, &MyApp.some_func/1 do
choice :choiceA, goto(:partA)
choice :choiceB, goto(:partB)
end
end
endMenu
The choice with a string content
in menu
defmodule MyApp.SceneName do
use DevJoy.Scene
part :menu do
menu "Menu title" do
choice "Menu item content", goto(:part_name)
end
end
endQuestion
The choice with a string content
in question
defmodule MyApp.SceneName do
use DevJoy.Scene
part :dialog do
question :john_doe, "Question content" do
choice "Answer content", goto(:part_name)
end
# or
question :john_doe, "Question content", some: :data do
choice "Answer content", goto(:part_name)
end
end
end
Summary
Field types
The type representing the action of the choice. The action is a 1-arity function which is called when the user chooses it's choice.
The type representing the choice's content. When it's an atom, it won't be translated. This is useful in conditions as we only want to compare it with a content returned by the action function.
Field types
The type representing the action of the choice. The action is a 1-arity function which is called when the user chooses it's choice.
The type representing the choice's content. When it's an atom, it won't be translated. This is useful in conditions as we only want to compare it with a content returned by the action function.