Skip to content

Commit

Permalink
Add definitions for item links api
Browse files Browse the repository at this point in the history
  • Loading branch information
brainiac committed Sep 6, 2024
1 parent 0b8e322 commit bf23769
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mq/_constants.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---@meta

---@class Mq
---@field MAX_AUG_SOCKETS integer
103 changes: 103 additions & 0 deletions mq/_itemlinks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---@meta

---@enum LinkTypes
mq.LinkTypes = {
Item = 0,
Player = 1,
Spam = 2,
Achievement = 3,
Dialog = 4,
Command = 5,
Spell = 6,
Faction = 7,
Invalid = -1,
}


---@class TextTagInfo
---@field type LinkTypes
---@field link string
---@field text string
local TextTagInfo = {}


---@class DialogLinkInfo
---@field keyword string
---@field text string
local DialogLinkInfo = {}


---@class ItemLinkInfo
---@field itemID integer
---@field sockets integer[]
---@field socketLuck integer[]
---@field isEvolving boolean
---@field evolutionGroup integer
---@field evolutionLevel integer
---@field ornamentationIconID integer
---@field luck integer
---@field itemHash integer
---@field itemName string
local ItemLinkInfo = {}

---@return boolean
function ItemLinkInfo:IsSocketed() end


---@class SpellLinkInfo
---@field spellID integer
---@field spellName string
local SpellLinkInfo = {}


--- Extracts all links from the given string, returning them in an array
---@param line string The text line to extract links from
---@return TextTagInfo[]
function mq.ExtractLinks(line) end

--- Executes a link as if it has been clicked by the user
---@param link TextTagInfo
function mq.ExecuteTextLink(link) end

--- Format an achievement into an achievement link
---@param achievement achievement
---@param playerName string
---@return string
function mq.FormatAchievementLink(achievement, playerName) end

--- Format text into a dialog link
---@param keyword string
---@param text string
---@return string
function mq.FormatDialogLink(keyword, text) end

--- Format an item into an item link
---@param item item
---@return string
function mq.FormatItemLink(item) end

--- Format a spell into a spell link
---@param spell spell
---@param nameOverride? string Optional override for the spell name
---@return string
function mq.FormatSpellLink(spell, nameOverride) end

--- Parse a dialog link from a line of text
---@param line string
---@return DialogLinkInfo
function mq.ParseDialogLink(line) end

--- Parse an item link from a line of text
---@param line string
---@return ItemLinkInfo
function mq.ParseItemLink(line) end

--- Parse a spell link from a line of text
---@param line string
---@return SpellLinkInfo
function mq.ParseSpellLink(line) end

--- Strip links from a line of text
---@param line string
---@return string
function mq.StripTextLinks(line) end
7 changes: 6 additions & 1 deletion mq/mq.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ function mq.bind(command, callback) end
---@param command string e.g /burn
function mq.unbind(command) end


---@class EventOptions
---@field keepLinks boolean

---Creates an event that will execute a Lua function when the provided matcher text is seen in game
---Note: this needs to be paried with #doevents() to actually process the events during the script execution.
---@param name string Name of the Event
---@param matcherText string # This needs an example and reference
---@param callback function # Function to call when text is matched
function mq.event(name, matcherText, callback) end
---@param options? EventOptions
function mq.event(name, matcherText, callback, options) end

---Unregisters the event by name so that it will no longer react
---@param name string # Name of the Event
Expand Down

0 comments on commit bf23769

Please sign in to comment.