I asked a lass to pass me a glass
of Engels' Condition of the Working Class

# 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} ",";
)
design by almost sweet - resources