API:CreateHyperLink
From RoR Wiki
UI Lua API · Interface functions
Version: WAR 1.4.8
Builds the markup for a clickable link that can be put into chat or label text.
link = CreateHyperLink(data, text, color, color2)
Arguments
- data
wstring– The link's data string, for exampleL"PLAYER:"..name. The stock UI starts it with a tag that tells what kind of link it is.- text
wstring– The text shown for the link.- color
number-table– Colour of the link as{r, g, b}on a 0–255 scale, or{}for no colour.- color2
number-table– A second colour in the same form, or{}. The stock UI always passes{}.
Returns
- link
wstring– The markup, for example<LINK data="PLAYER:Name" text="Name" color="255,255,255">.
Details
- The result has the form
<LINK data="data" text="text">. Each colour table adds acolor="r,g,b"attribute before the closing>; with both tables filled the markup has twocolorattributes. - A colour table is used only if it has at least three entries; only the first three are read. Each value is clamped to 0–255 and written as a whole number.
dataandtextare copied as they are. Quotes or>characters in them are not escaped.dataandtextmust be wide strings. Passing a plain Lua string raises an Invalid Parameters error.- The function needs at least four arguments and only reads the last four.
Errors
None besides the Invalid Parameters argument check.
Example
Inserting an item link into the chat input, from ea_chatwindow/source/chathyperlinking.lua:
local data = ITEM_TAG..itemData.uniqueID
local text = L"["..itemData.name..L"]"
local color = DataUtils.GetItemRarityColor(itemData)
local link = CreateHyperLink( data, text, {color.r,color.g,color.b}, {} )
EA_ChatWindow.InsertText( link )
A player link without a colour, from ea_guildwindow/source/guildwindowtabrecruitsearch.lua:
local text = CreateHyperLink( L"PLAYER:"..name, name, {}, {} )
