Custom Dialogues - Jondoty/Johto GitHub Wiki
The primary way I re-tell the story of the Pokemon games is through what I call Dialogues. Below I'll go through an example dialogue and display what is recommended to modify to change the displayed dialogue in Minecraft, for purposes such as translations.
The main dialogue.mcfunction file stores the contents of the story that plays throughout the game. The file is located at Johto/data/functions/custom.
This system requires two dummy scoreboards in Minecraft itself. /scoreboard objectives add DialogueTrigger dummy /scoreboard objectives add TalkTime dummy
DialogueTrigger is used as an event trigger by giving the player a specific number which then tells the function what dialogue to display.
TalkTime is a value that is added about ~1.4 times per second on average, or the time a 1x2 hopper clock will refresh. This is intentionally ran through a hopper clock to reduce lag, as opposed to the repeating command block frequency of 20 ticks per second.
This is the command that activates the dialogue. It can be ran by a unique command block within the spawn chunks or by another function itself. Essentially every dialogue trigger is specified using Minecraft's target selectors.
scoreboard players set @a[x=-958,y=66,z=-366,dy=2,dz=1,score_TalkTime=0,tag=!Dialogue1] DialogueTrigger 1
Points to specify:
- This command sets a DialogueTrigger score, usually by visiting a location, having a certain item, having an item in a location, or triggered when player accepts a quest.
- These are triggered externally from the primary dialogues.mcfunction or any language variants.
- A score_TalkTime=0 selector is used as to ensure player is not in a current dialogue, as changing DialogueTrigger values mid-dialogue would cause skips in effects and story outcomes.
- tag=!Dialogue1 used to ensure player hasn't heard this dialogue before, and won't repeat unless tag specifically removed. All dialogues have a unique number.
scoreboard players add @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1] TalkTime 1
- Adds a score of 1 every time function is ran, counting up and used as a timing device for commands following it.
- Timings are added at the pace of two hoppers feeding one item into each other, and having one hopper's signal read using a comparator, accounting for about 1.4 refreshes a second.
tellraw @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1,score_TalkTime_min=1,score_TalkTime=1] {"text":"<...> Hello! Sorry to keep you waiting!"}
Example of a Tellraw command that will occur at timing value 1
- Translations will likely just want to modify the tellraw speech between the {} and [] brackets of the tellraw data. Timing changes may also be necessary if language is more or less dense with information per character.
Example translation:
tellraw @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1,score_TalkTime_min=1,score_TalkTime=1] {"text":"<...> ¡Bienvenido al mundo de Pokémon!"}
tellraw @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1,score_TalkTime_min=8,score_TalkTime=8] {"text":"<...> Welcome to the world of Pokémon!"}
- Difference in TalkTime values between commands determines how much of a delay there is. A difference of 7 is about my minimum gap between short sentences.
- A hopper clock that is two hoppers going back and forth, comparator out of one end, runs at about 100 TalkTime additions per 70 realtime seconds.
execute @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1,score_TalkTime_min=22,score_TalkTime=22] ~ ~ ~ give @s pixelmon:rare_candy
execute @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=!Dialogue1,score_TalkTime_min=22,score_TalkTime=22] ~ ~ ~ /tp @e[x=-744,y=74,z=-242,dy=3,type=pixelmon:statue] -964.5 66 -406.0
- Executes commands as the player, sometimes on the world (npcs tping in or out, particles, etc). Commands other than the execute can use the @s selector for only the player with this dialogue at this specific time.
scoreboard players tag @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,score_TalkTime_min=22,tag=!Dialogue1] add Dialogue1
scoreboard players set @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,score_TalkTime_min=22,tag=Dialogue1] TalkTime 0
scoreboard players set @a[score_DialogueTrigger_min=1,score_DialogueTrigger=1,tag=Dialogue1] DialogueTrigger 0
- Ends the dialogue, and adds a tag as to not repeat.
- Target selector of score_TalkTime_min=X is what will determine the ending time. This should be equal to or greater than the final command in the series.
Without comments, a dialogue looks about like
#Mom's opening dialogue when you walk downstairs` #scoreboard players set @a[x=-736,y=64,z=-491,dx=10,dy=3,dz=6,tag=!Dialogue2,score_TalkTime=0] DialogueTrigger 2
scoreboard players add @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=!Dialogue2] TalkTime 1
tellraw @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=!Dialogue2,score_TalkTime_min=2,score_TalkTime=2] ["",{"text":"<Mom> Oh, "},{"selector":"@p[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=!Dialogue2,score_TalkTime_min=2,score_TalkTime=2]"},{"text":"...!"}]
tellraw @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=!Dialogue2,score_TalkTime_min=8,score_TalkTime=8] {"text":"<Mom> Our neighbor, Professor Elm, was looking for you."}
tellraw @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=!Dialogue2,score_TalkTime_min=17,score_TalkTime=17] {"text":"<Mom> He said he wanted you to do something for him."}
scoreboard players tag @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,score_TalkTime_min=17,tag=!Dialogue2] add Dialogue2
scoreboard players set @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,score_TalkTime_min=17,tag=Dialogue2] TalkTime 0
scoreboard players set @a[score_DialogueTrigger_min=2,score_DialogueTrigger=2,tag=Dialogue2] DialogueTrigger 0