ConversationSpell - TheComputerGeek2/MagicSpells GitHub Wiki
Source Code
spell-class: ".targeted.ConversationSpell"
Value |
Supported |
entity |
true |
location |
false |
entity_from_location |
false |
Description:
Opens a chat prompt that can be used to store the target's response in a variable. This is a targeted spell, so remember to use target-self: true
to capture the caster's response instead.
Configuration:
Option |
Description |
conversation |
Starts a section with a number of options. Will fail if not defined. |
Conversation Options:
Option |
Description |
Type |
Default |
prefix |
Accepts a string. |
String |
|
local-echo |
Whether or not to let the player see their responses in chat. |
Boolean |
true |
timeout-seconds |
The amount of time until the conversation automatically closes. |
Integer |
30 |
escape-sequence |
The string (in quotes) the player can send to exit the conversation spell. |
String |
|
first-prompt |
Name is misleading - you can only have one prompt. Starts a section with several options. It will fail if not defined. |
Prompt Options |
|
Prompt Options:
Option |
Description |
prompt-type |
Accepts the values regex , fixed-set , or enum . |
prompt-text |
Accepts a string. The message that will be sent to the player upon the spell being cast. |
variable-name |
The variable to save the response to. |
Expand that same section with the prompt type's specific options. For:
regex
- add regexp
option which accepts a valid RegExp string. To capture any chat message, set this to .*
fixed-set
- add an options
string list for valid expected responses.
enum
- add enum-class
string with the full qualified class name of an enum. For example, limit valid responses to Paper's potion effect types by setting the string to the package and class name: org.bukkit.potion.PotionEffectType
.
Example:
variables:
response:
type: playerstring
Conversation:
spell-class: ".targeted.ConversationSpell"
target-self: true
conversation:
prefix: "&3&l[&bQuest&3&l] &7"
local-echo: true
first-prompt:
prompt-type: fixed-set
prompt-text: |
Are you a magic user? Can you help me?
&3Do you want to accept this quest? §bType your response!
&7- &aYes
&7- &cNo
options:
- "Yes"
- "No"
variable-name: response
timeout-seconds: 6
escape-sequence: "Exit"
The example below shows a way to cast a spell to utilise the response as soon as one is captured.
variables:
response:
type: playerstring
await_response:
spell-class: ".MultiSpell"
variable-mods-cast: [response =unset]
spells: [conversation, conversation_loop]
conversation:
spell-class: ".targeted.ConversationSpell"
helper-spell: true
target-self: true
conversation:
local-echo: false
timeout-seconds: 10
escape-sequence: "Exit"
first-prompt:
prompt-type: regex
prompt-text: "&3Enter password:"
regexp: ".*"
variable-name: response
conversation_loop:
spell-class: ".targeted.LoopSpell"
helper-spell: true
duration: 10 * 20
interval: 10
targeted: false
cancel-on-death: true
spells: [check_response]
check_response:
spell-class: ".MultiSpell"
helper-spell: true
modifiers: [variablestringequals response=unset deny]
spells: [report_response(mode=full), stop_loop]
stop_loop:
spell-class: ".targeted.CleanseSpell"
helper-spell: true
target-self: true
remove: ["loop:conversation_loop"]
report_response:
spell-class: ".instant.DummySpell"
helper-spell: true
str-cast-self: "%var:response%"