API:GetDyeMerchantData
From RoR Wiki
UI Lua API · Dye functions
Version: WAR 1.4.8
Returns the colours offered by the dye merchant the player is talking to.
dyes = GetDyeMerchantData()
Arguments
None.
Returns
- dyes
table– Array of colour tables, indexed from 1, plus anumColorsfield.
The table has this extra field:
| Key | Type | Meaning |
|---|---|---|
numColors |
number |
Number of colours. The stock UI loops from 1 to this value. |
Each colour table has these fields:
| Key | Type | Meaning |
|---|---|---|
cost |
number |
Price of the colour, in brass. |
id |
number |
Position of the colour in the list, starting at 0 (one less than the array index). |
dataIndex |
number |
– (the stock UI copies it to GameData.DyeMerchant.tintA/tintB before buying).
|
paletteIndex |
number |
Index of the colour in the client's dye palette. Pass it to DyeMerchantPreview. The stock UI treats 0 as bleach. |
r, g, b |
number |
Colour of the palette entry, 0–255 each. |
Details
- The data is the dye merchant list the client currently holds. A new table is built on every call.
numColorsis a separate value the client keeps next to the list; it is not counted from the entries. The stock UI relies on it.- The table can be passed straight to ColorPickerCreateWithColorTable, which reads
id,r,gandb. - If the Lua state is not available, the function returns nothing.
Errors
None.
Example
From default/ea_characterwindow/source/characterwindowdyes.lua:
CharacterWindow.dyeColors = GetDyeMerchantData()
CharacterWindow.dyeColorsLookUp = {}
local bleachId = nil
for index = 1, CharacterWindow.dyeColors.numColors
do
if( CharacterWindow.dyeColors[index].paletteIndex == 0 )
then
bleachId = CharacterWindow.dyeColors[index].id
end
CharacterWindow.dyeColorsLookUp[ CharacterWindow.dyeColors[index].paletteIndex ] = CharacterWindow.dyeColors[index]
end
ColorPickerCreateWithColorTable("DyeMerchantColorPicker", CharacterWindow.dyeColors, 5, 10, 10)
