Thanks for the help Gwendo, the (AT variable) does it. I did not know about it before. I now have:
COPY_EXISTING ~%spell_res%.spl~ ~override~
LAUNCH_PATCH_FUNCTION ~APPLY_DESC_SPL~
INT_VAR desc_traentry = 17081 // tra entry number
END
Along with:
DEFINE_PATCH_FUNCTION ~APPLY_DESC_SPL~
INT_VAR
name_strref = "-1" // Use a specific string or RESOVLVE_STR_REF ()
desc_strref = "-1" // Use a specific string or RESOVLVE_STR_REF ()
name_traentry = "-1" // Use a .tra entry number (i.e. 0 for @0)
desc_traentry = "-1" // Use a .tra entry number (i.e. 0 for @0)
STR_VAR
name_text = "" // Set strings brute force method (not recommended)
desc_text = "" // Set strings brute force method (not recommended)
BEGIN
PATCH_IF
("%SOURCE_FILE%" STRING_MATCHES_REGEXP "^.+\.spl$" = 0 AND BUFFER_LENGTH > 0x71)
AND (NOT "%name_text%" STRING_EQUAL_CASE "" OR NOT "%desc_text%" STRING_EQUAL_CASE ""
OR name_strref >= 0 OR desc_strref >= 0 OR name_traentry >= 0 OR desc_traentry >= 0)
BEGIN // Sanity check
// Write name
PATCH_IF name_strref >= 0 BEGIN // If %name_strref% is set
SAY NAME1 name_text
END ELSE
PATCH_IF name_traentry >= 0 BEGIN // If %name_traentry% is set
SPRINT name_text (AT name_traentry)
END
PATCH_IF NOT "%name_text%" STRING_EQUAL_CASE "" BEGIN // If %name_text% is set
SAY_EVALUATED NAME1 "%name_text%"
END
// Write description
PATCH_IF desc_strref >= 0 BEGIN // If %desc_strref% is set
SAY UNIDENTIFIED_DESC desc_text
END ELSE
PATCH_IF desc_traentry >= 0 BEGIN // If %desc_traentry% is set
SPRINT desc_text (AT desc_traentry)
END
PATCH_IF NOT "%desc_text%" STRING_EQUAL_CASE "" BEGIN // If %desc_text% is set
// Record spell-related data here
SAY_EVALUATED UNIDENTIFIED_DESC "%desc_text%"
END
END
END