Show a quest journal
Build a small Lua window from your available, active, and completed quest IDs.
Save the following as Scripts/modules/quest_journal/main.lua, then Load it
from the Scripts tab. It refreshes the three quest lists every two seconds and
shows their IDs in a window. Edit the names and layout to make it your own.
local ui_sdk = require("ui_sdk")
local journal = { available = {}, active = {}, completed = {} }
local message = "Waiting for a character"
local function summary(ids)
if #ids == 0 then return "none" end
local shown = {}
for index = 1, math.min(#ids, 8) do
shown[#shown + 1] = ids[index]
end
local suffix = #ids > 8 and ", ..." or ""
return #ids .. " (" .. table.concat(shown, ", ") .. suffix .. ")"
end
local function refresh()
local available, availableError = game.available_quest_ids()
local active, activeError = game.active_quest_ids()
local completed, completedError = game.completed_quest_ids()
if not available or not active or not completed then
message = availableError or activeError or completedError
return
end
journal.available = available
journal.active = active
journal.completed = completed
message = "Quest lists updated"
end
function on_start()
local ok, err = script.start_worker(function()
while true do
refresh()
script.sleep(2000)
end
end)
if not ok then log.warn(err) end
end
function on_tick()
local ok, err = ui_sdk.window("quest_journal", "Quest journal", {
x = 80, y = 120, width = 330, height = 230,
}, function(ui)
ui.text(message)
for _, group in ipairs({ "available", "active", "completed" }) do
ui.text(group .. ": " .. summary(journal[group]))
end
end)
if not ok then log.warn(err) end
endAn empty array means that the list is available and has no entries. If a read
returns nil, error, the window keeps the last successful list and shows the
error. These functions return quest IDs; they do not return the quest UID
needed by game.submit_quest. The lists preserve the game's current order.
To request a known available quest, pass its ID to game.claim_quest(id) and
read the lists again afterward. A successful request alone does not mean the
quest changed. See quest actions for the
different arguments to claim, execute, and submit.