fly me to the moon

Free Scripts

I asked a lass to pass me a glass
of Engels' Condition of the Working Class
An animated gif of a siamese cat sitting on a keyboard while someone uses an art program.

Multi-name Teach [YAYA]

When writing CHIPS, I decided to create a robust name system that allowed users to set as many or as few names for the Ghost to call them as they wanted.

Then, as an exercise, I decided to rewrite that feature in YAYA, too. That also had the benefit of being more accessible to people who did not know Kawari. It's pretty big, so please open it in another tab to copy it:

Multi-name Teach

Check surfaces [Kawari]

(7/5/2023)

This is an adaptation of Zichqec's Check surfaces code. It was originally in YAYA, this version is for Kawari.

This is useful for if a Ghost uses multiple shells but not the same amount of surfaces, or just as a backup.

# The majority of the code is in OnTranslate
OnTranslate : $(
    # This bit of code that checks if a surface is valid was 
    # adapted from a YAYA equivalent created by Zichqec. 
    # Be aware that it will replace 
    # the Kero's invalid surfaces with surface0 as well.

    # Make an array of the current dialogue, 
    # with each element starting with a surface call
    setstr @talk $(Reference 0);
    split @checksurfaces ${@talk} "\s[";

    # Erase the first element 
    # since it won't have a surface call
    clear @checksurfaces[0];

    # Split off the rest of this bit of dialogue
    # so that we just have the surface number
    foreach @element @checksurfaces $(split @surface ${@element} "]");

    # If it isn't valid, as in not present in ValidSurfaces, 
    # replace it. ValidSurfaces is found in NotifyShellInfo.
    foreach @element @surface $(
        setstr @isvalid $(find ValidSurfaces ${@element}); 
        if $[ ${@isvalid} = -1 && ${@element} >= 0 ] $(
            setstr @talk $( gsub ${@talk} "\s["${@element}"]" "\s[0]" );
        );
    );
    clear @surface; clear @isvalid;
        # Returns the new version
        echo ${@talk};
)
# You also need this part in OnNotifyShellInfo, 
# to inform what surfaces are valid.
OnNotifyShellInfo : $(
    # @reference2 is the list of surfaces in the shell, pre-processing
    setstr @reference2 $(Reference 2);
    # Turns it into our final array
    split ValidSurfaces ${@reference2} ",";
)

credit

design by almost sweet - resources