Add Lua bindings for journal, as well as engine handler
This MR adds the quests table to types.Player, which is a function that requires the player.
This table is indexed by quest ID, so this would return every started quest: for x, quest in pairs(types.Player.quests(playerRef)) do print (quest.name) end
If you specify an index, you can request info about a started or non-started quest:
types.Player.quests(playerRef)["ms_fargothring]
When you set a variable here(from a global script) it will start the quest for the player, if it's not started yet, and it will show up in the quests list on the player.
Each quest table item has 4 fields:
- id, which is just the quest ID("ms_fargothring")
- stage, which is the quest stage or index. Starts at 0, returns -1 if the quest is not yet started(should maybe return nil?)
- isFinished, which is pretty obvious. You can set this from a global script. If it is true, it will not show up in the player's quest journal by default.
- name, which is the user friendly name("Fargoth's ring"). This will be nil before the quest is started.
They also have a function, addJournalEntry(actor, stage), which accepts an actor, and a stage int. The actor will be used in case the text of the journal entry contains keywords like %Name, the stage will determine which journal entry is added to the player's journal.
I want to add core.Journal to include data about all journal entries, but I think that should happen after this MR.
This MR also adds an engine handler for when quest stages are updated. It is called to the player. Here's an example:
local function onQuestUpdate(id, index)
print(id, index)--output: mg_bcshrooms 100
print(types.Player.quests(self)[id].stage) -- 100
end