Jump to content


Mike1072

Member Since 28 Jan 2005
Offline Last Active Yesterday, 08:45 PM

Posts I've Made

In Topic: Help with first mod ideas

13 June 2019 - 06:22 PM

Your patches for the COPY_EXISTING (SAY and BUT_ONLY) aren't executing on it because ACTION_IF starts a new action.

 

You need to use PATCH_IF there instead.

 

I'd also update the regexp check to be a little more robust and to toss in the comparison with its matching return value, as mentioned previously:

(~%resource%~ STRING_MATCHES_REGEXP ~.+\.spl~ == 0)

In Topic: Help with first mod ideas

08 June 2019 - 11:24 PM

You can check the IESDP for file offsets.  You can also enable the setting 'View Hex Offets' in Near Infinity, which will display the offset next to each field on the Edit tab.

 

The unidentified name is at offset 0x08.

 

If you want to read the string directly, you can use READ_STRREF.  It's equivalent to READ_LONG plus GET_STRREF.

 

To do a string comparison, you can't use ==.  You have to use one of the string comparison operators, like STRING_EQUAL or STRING_COMPARE.  You also have to wrap your variable name in quotes and use percent signs to evaluate it, to ensure you are comparing the variable's value and not the variable's name.

 

Be warned that STRING_EQUAL (sensibly) returns 1 when there is a match, but the STRING_COMPARE and STRING_MATCHES_REGEXP variants return 0 when there is a match. These two expressions are equivalent:

(~%str_item_type%~ STRING_COMPARE ~Scroll~ == 0)
(~%str_item_type%~ STRING_EQUAL ~Scroll~)

In Topic: Help with first mod ideas

07 June 2019 - 04:01 PM

You need to include a component declaration (e.g. BEGIN ~Name of Component~), after your LANGUAGE statement.

There are also several errors in your .tra file. You are missing the equals sign between the reference and string (e.g. @100650 = ~Abazigal Shockwave~) and there is one .tra reference with no associated string (@100350).

In Topic: Help with first mod ideas

03 June 2019 - 04:27 PM

Storing filenames in .tra files is a strange way of doing things.

To match filenames with spell names and spell descriptions, I'd recommend either an associative array in your .tp2 code or a separate .2da file.  I'd probably go with a .2da file.
 
AlonsosMod/spells.2da:
         NAME    DESC
BALSHLD  100002  100003
BALSHLD2 100005  100006
 
AlonsosMod.tp2:
COPY - ~AlonsosMod/spells.2da~ ~AlonsosMod/spells.2da~
  READ_2DA_ENTRIES_NOW ~r2en_spells~ 3
  FOR (row = 0; row < r2en_spells; row += 1) BEGIN
    READ_2DA_ENTRY_FORMER ~r2en_spells~ row 0 resource
    READ_2DA_ENTRY_FORMER ~r2en_spells~ row 1 name
    READ_2DA_ENTRY_FORMER ~r2en_spells~ row 2 desc
    
    INNER_ACTION BEGIN
      ACTION_IF (FILE_EXISTS_IN_GAME ~%resource%.spl~) BEGIN
        COPY_EXISTING ~%resource%.spl~ ~override~
          SAY NAME1 (AT name)
          SAY UNIDENTIFIED_DESC (AT desc)
          BUT_ONLY
      END
    END
  END

In Topic: Help with first mod ideas

22 May 2019 - 04:48 PM

You should only use .tra references for strings that need to be translated to different languages.  Filenames don't need to be translated.