jastey Posted February 26, 2023 Share Posted February 26, 2023 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. Quote Link to comment
jastey Posted February 26, 2023 Author Share Posted February 26, 2023 I solved it differently for now, but I'd still be interested for future occasions. Quote Link to comment
argent77 Posted February 26, 2023 Share Posted February 26, 2023 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 Quote Link to comment
jastey Posted February 26, 2023 Author Share Posted February 26, 2023 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). Quote Link to comment
argent77 Posted February 26, 2023 Share Posted February 26, 2023 That should work just the same. Only the OUTER_PATCH_SAVE block isn't needed in that case. Quote Link to comment
jastey Posted February 26, 2023 Author Share Posted February 26, 2023 Great, thanks! Here I was, thinking I could use GET_STRREF like STATE_WHICH_SAYS or something. Quote Link to comment
jastey Posted February 26, 2023 Author Share Posted February 26, 2023 One question: why would it only work for EE? Quote Link to comment
argent77 Posted February 26, 2023 Share Posted February 26, 2023 Because of the FILE_CONTAINS_EVALUATED() check in bgee.lua. Without any checks the whole code could be reduced to WITH_TRA ~path/to/other_mod/tra/%LANGUAGE%/mod.tra~ BEGIN OUTER_SET title_strref = RESOLVE_STR_REF(@100) END Quote Link to comment
jastey Posted February 26, 2023 Author Share Posted February 26, 2023 Great, thank you! Quote Link to comment
Recommended Posts
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.