Jump to content

Need syntax to use GET_STRREF to get a string added by a mod


jastey

Recommended Posts

Quote
GET_STRREF value variable The string reference value is looked up in DIALOG.TLK and the (male) string (without any quotes) is stored in the variable.

I want to get the strref number for a journal title which was added by another mod. The string I want to be looked up by giving the tra path. Could someone give me the syntax how I would do that? Maybe I need ACTION_GET_STRREF - I have no idea. I also don't know whether this is a tp2, a d- thing, or whether I'd need to wrap it into a function (or whatever). Thanks in advance.

Link to comment

If this is for EE games then this may work:

Spoiler
DEFINE_ACTION_FUNCTION get_journal_title
INT_VAR
  tra_ref = "-1"      // tra reference of a journal entry
STR_VAR
  tra_path = ~~       // path to (external) tra file
RET
  title title_strref  // returns journal title and associated strref
BEGIN
  OUTER_SPRINT title ~~
  OUTER_SET title_strref = "-1"

  ACTION_IF (FILE_EXISTS ~%tra_path%~) BEGIN
    WITH_TRA ~%tra_path%~ BEGIN
      OUTER_SET strref = RESOLVE_STR_REF((AT "tra_ref"))  // resolve tra reference to strref
      ACTION_GET_STRREF strref text   // load string from strref

      // extracting first line (title) of journal entry
      OUTER_PATCH_SAVE title ~%text%~ BEGIN
        SET eol = INDEX_BUFFER(~[%WNL%]~)
        PATCH_IF (eol >= 0) BEGIN
          DELETE_BYTES eol (BUFFER_LENGTH - eol)
        END
      END
      OUTER_SET title_strref = RESOLVE_STR_REF(~%title%~)

      // checking if the journal title actually exists in the game
      ACTION_IF NOT FILE_CONTAINS_EVALUATED(~bgee.lua~ ~createQuest[ %TAB%]*([ %TAB%]*%title_strref%[ %TAB%]*)~) BEGIN
        OUTER_SPRINT title ~~
        OUTER_SET title_strref = "-1"
      END
    END
  END
END

LAF get_journal_title
  INT_VAR tra_ref = 100 // tra reference pointing to a journal entry (or title)
  STR_VAR tra_path = EVAL ~path/to/other_mod/tra/%LANGUAGE%/mod.tra~
  RET title title_strref
END

ACTION_IF title_strref >= 0 BEGIN
  PRINT ~Journal title found: "%title%" (strref=%title_strref%).~
END ELSE BEGIN
  PRINT ~Could not find journal title.~
END

 

Link to comment

Oh, I should have been more specific. What I want is to get the stringref number of a string that I have a tra path to. I don't need to extract the title from a normal journal entry, I have a tra line number for the journal title (and it was added as an own stringref).

I should have asked how to get a stringref number of a string added by a mod when I "know" the string in question (via tra path).

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...