Add Lua read access to TES3 player's journal records
Wait, wasn't that feature request posted already?
I did post #7964 (closed), which proposed to expose the game dialogue records to Lua. But that would only allow to get 'raw' text data from content files - basically access the same information as you access from the CS. So for example if you use the current proposal !4034 (merged), which implements this access, and write a script to get
local aa = core.dialogue.topic.records['advancement'].infos[100].text
then in vanilla MW that aa
variable is a string: "Congratulations, %PCName. You are now %PCName the %NextPCRank.". (By the way it's not only a topic dialogue thing - there are also journal entries with %variable placeholders. A handful in vanilla MW, but still, they are not static sadly.)
You probably could fill in all these blanks in Lua scripts already and create a proper string to be used in dehardcoded dialogue window or to be recorded in a dehardcoded journal. But that would only work for texts made at that specific moment. Game journal/topic records gathered by the player are stored in game saves as full texts, with %variables filled at the moment of recording them, which means that there are at least four pieces of info the previous API can't get:
- %variables - for example the player's rank in the faction may be different right now than 20h of playtime ago, but the journal should have a record for the old value used back then;
- Journal/topic order in which the player recorded them in journal;
- Date - every journal entry has a game date. Of course unique to the player, who may have talked to Caius Cosades on day1, or day100
😜 ; - Name of the actor who spoke a dialogue line - also unique to the player, as they may have asked a different NPC about the topic shared between many characters.
How would it work?
Previous API is on openmw.core
. This one, as it'd be tied to the player's data (I think the openmw journal is a global data currently if I understood the code correctly, but still, I heard we should have future multiplayer in mind so that may change in code eventually), should be in openmw.types.Player
, just like the already existing PlayerQuest. So my proposal is for an openmw.types.Player.journal
field, which provides the read only (at least initially) access to journal text entries and topic text entries. Each journal text entry would also hold the relevant quest id (if it exists), so it could also be combined with the previous api.
Actually, I made a draft for this, which I planned to post as a MR if !4034 (merged) is merged: