Jump to content

TP2 file coding questions


svj

Recommended Posts

I had look at original game files and they do delete journal entries by specifying string reference number which i for obvious reasons i do not have.

How do mods delete journal entries?

Should i just add entries to user journal? and let users to delete entries?

Link to comment
EraseJournalEntry(RESOLVE_STR_REF(Assasination Contract Marcian Argent.

I have agreed to kill Marcian Argent for Dwarf Rugos Mithrest Inn. He is supposed to be somewhere in Graveyard District i should be expecting Marcian to be protected by at least two Priests, several Fighters and one Wizard.))

I have grepped my entire unpacked modding/games folder and nobody is using this function.

How is this thing supposed to be used?

Link to comment

RESOLVE_STR_REF is a WeiDU command that goes in the tp2 file; look it up in the WeiDU documentation for the syntax. Your sample there absolutely won't work, because EraseJournalEntry is a script action that goes in a completely different place.

So, here's a sample that does work:

In the .tp2 file:

SET journal1 = RESOLVE_STR_REF(@12345) // Assume @12345 is the desired journal entry.
// More stuff. Probably unrelated.
COMPILE EVALUATE_BUFFER ~mymod/quest.d~ // Compile the dialogue, evaluating variables.

In the .D file:

/* Stuff, including a response for this action to attach to */
DO AddJournalEntry(%journal1%)
/* More stuff */
DO EraseJournalEntry(%journal1%)

Or you can just use that same @12345 reference directly in both places instead of the variable; the system is smart enough to handle that properly. That's what the file I looked at did, anyway.

Link to comment

For own journal entries, you just take the exact same text you used for adding it to the journal:

EraseJournalEntry(~Text of the journal entry~)

Or, if you work with tra files (which is recommended in this case, so the text is the exact same:

EraseJournalEntry(@12345)

The text need to match 100% with what the added journal entry was, or the journal entry will not be removed.

The RESOLVE_STR_REF is for original game journal entries.

There is also another way to fetch these: the func_fetch_journal_entries.tph fetches them from a dialogue state directly. It is used in the bg1re mod, for example.

Link to comment
IF ~~ THEN BEGIN Rugos1HaveHead
    SAY ~Show it to me...Hmm....appearance matches. Here is your gold, Talk to me when you are ready to take another contract, Farewell.~
    IF ~~ THEN DO
        ~GiveGoldForce(12000)
        SetGlobal("rqcontractKamraarn","GLOBAL",1)~
        SOLVED_JOURNAL ~Assassination Contract: Marcian Argent completed.~
        EraseJournalEntry(~Assassination Contract Marcian Argent.

        I have agreed to kill Marcian Argent for Dwarf Rugos in Mithrest Inn. He is supposed to be somewhere in Graveyard District i should be expecting Marcian to be protected by at least two Priests, several Fighters and one Wizard.~)
    EXIT
END

This produces parse error you sure this is the right way to do it?

Edited by svj
Link to comment

The parse error is because you have that EraseJournalEntry floating in the wrong place, rather than in the action block (DO ~~). That's where script actions go. When the system tries to parse this response, it sees an empty condition trigger, an action block, a SOLVED_JOURNAL entry, and then something which isn't a transition flag or a valid end to the response. Parse failed.

In other words, to fix it, put the EraseJournalEntry into the action block where it belongs.

Link to comment

EraseJournalEntry is a scripting action, so it properly needs to be inside the DO, e.g.

IF ~~ THEN BEGIN Rugos1HaveHead
    SAY ~Show it to me...Hmm....appearance matches. Here is your gold, Talk to me when you are ready to take another contract, Farewell.~
    IF ~~ THEN DO
        ~GiveGoldForce(12000)
        SetGlobal("rqcontractKamraarn","GLOBAL",1)
        EraseJournalEntry(~Assassination Contract Marcian Argent.

        I have agreed to kill Marcian Argent for Dwarf Rugos in Mithrest Inn. He is supposed to be somewhere in Graveyard District i should be expecting Marcian to be protected by at least two Priests, several Fighters and one Wizard.~)~
        SOLVED_JOURNAL ~Assassination Contract: Marcian Argent completed.~        
    EXIT
END
Link to comment
IF ~~ THEN BEGIN Rugos1HaveHead
    SAY ~Show it to me...Hmm....appearance matches. Here is your gold, Talk to me when you are ready to take another contract, Farewell.~
    IF ~~ THEN DO
        ~GiveGoldForce(12000)
        SetGlobal("rqcontractKamraarn","GLOBAL",1)
        EraseJournalEntry(~Assassination Contract Marcian Argent.

        I have agreed to kill Marcian Argent for Dwarf Rugos in Mithrest Inn. He is supposed to be somewhere in Graveyard District i should be expecting Marcian to be protected by at least two Priests, several Fighters and one Wizard.~)~
        SOLVED_JOURNAL ~Assassination Contract: Marcian Argent completed.~
    EXIT
END

[action list near line 95, column 28 of revan/d/rqrugos.d] PARSE WARNING at line 97 column 1-26
Near Text:
       syntax error
WARNING: cannot verify action ~GiveGoldForce(12000)
       SetGlobal("rqcontractKamraarn","GLOBAL",1)
       EraseJournalEntry(~: Parsing.Parse_error

[revan/d/rqrugos.d] PARSE ERROR at line 95 column 1-40
Near Text: Assassination
       syntax error

[revan/d/rqrugos.d]  ERROR at line 95 column 1-40
Near Text: Assassination
       Parsing.Parse_error
ERROR: parsing [revan/d/rqrugos.d]: Parsing.Parse_error
ERROR: compiling [revan/d/rqrugos.d]!
Stopping installation because of error.

ERROR Installing [Golden Horse mercenary company (Requires Throne of Bhaal)], rolling back to previous state
Will uninstall  29 files for [SETUP_REVAN.TP2] component 0.
Uninstalled     29 files for [SETUP_REVAN.TP2] component 0.
ERROR: Parsing.Parse_error



No workey sir.

Edited by svj
corrected misleading mod name
Link to comment

Okay. Now the parse error is something different. Because you used ~ to delimit the beginning of the action block, the system expects ~ to delimit the end of the block. And it finds that tilde, immediately after the left parenthesis. Which makes that an incomplete action that doesn't make sense.

That's why both ~ and " are accepted as string delimiters. Use one on the outside, use the other on the inside. If you're using ~ to delimit the action block, you need to use " to delimit the strings inside it. Such as "rqcontractKamraarn", or "GLOBAL", or that whole long journal string.

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...