ArisStudio / ArisStudio_Legacy

做你自己的碧蓝档案故事 | Make your own BlueArchive story(deprecated)
https://github.com/ArisStudio/ArisStudio_Legacy/wiki
GNU General Public License v3.0
264 stars 30 forks source link

alias command #20

Closed Tualin14 closed 1 year ago

Tualin14 commented 1 year ago

Repeating the txt, character name and their group is tiring. Example:

txt Hifumi 'Remedial Department' 'Ah, Sensei! You are here!'
txt Hifumi 'Remedial Department' 'Ne, just like what I told Sensei on MomoTalk, I just got new peripheral products.'

So, we use alias to resolve this issue. Instead of writing like above, we can use alias to save a specified text then use it later by simply writing the alias name.

Syntax: alias alias_name "alias content"

Example:

alias hifumi_say "txt Hifumi 'Remedial Department'" // save the 'txt' command, character name and their group first

hifumi_say 'Ah, Sensei! You are here!' // use them by simply write the alias name
hifumi_say 'Ne, just like what I told Sensei on MomoTalk, I just got new peripheral products.'

The output will be the same, but we write it more shortly.

The important note in here is that, you can't use the same alias name that has been given to another command. Example:

// we load the character with the alias name 'hifumi' so we can use it later to do other things like...
// changing the character state and emotion.
load spr hifumi hifumi_spr

// we define an alias with the name 'hifumi' (same as above) to store the txt.
alias hifumi "txt Hifumi 'Remedial Department'"

// in here, the problem will occur. Aris Studio didn't know whether you want to change the behavior...
// of the character or just print the text in the dialogue and the content is 'show'.
hifumi show
hifumi emo Action
hifumi state  03

hifumi 'Ah, Sensei! You are here!'
kiraio-moe commented 1 year ago

Trying to figure out, why using alias causing the story to continue run (except when selecting button) without showing the dialogue. Using the normal way is fine.

https://github.com/Tualin14/ArisStudio/assets/58289710/c95f5ff2-fd02-4143-8e1f-2cc7cef59405

kiraio-moe commented 1 year ago

Fixed! Instead of adding this line to PreLoad(string[] texts):

foreach (var kv in aliasList.Where(kv => text.Contains(kv.Key)))
{
    text = text.Replace(kv.Key, kv.Value);
}

place it in SolveCommand(string text):

...

if (nameIdList.ContainsKey(command[0]))
    textCommand = $"{nameIdList[command[0]]} {textCommand}";

foreach (KeyValuePair<string, string> alias in aliasList.Where(alias => textCommand.Contains(alias.Key)))
{
    // if current command contain alias name, replace the command with the alias value.
    textCommand = textCommand.Replace(alias.Key, alias.Value);
}

command = AsCommand.Parse(textCommand);

...
Tualin14 commented 1 year ago

26

Tualin14 commented 1 year ago

Archive this repository