<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ADyePreview</id>
	<title>API:DyePreview - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ADyePreview"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:DyePreview&amp;action=history"/>
	<updated>2026-10-17T18:49:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:DyePreview&amp;diff=30281&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:DyePreview&amp;diff=30281&amp;oldid=prev"/>
		<updated>2026-10-16T19:42:05Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Dye}}&lt;br /&gt;
Shows on the character how an equipped item would look with a dye from the player&amp;#039;s inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DyePreview(dyeLocation, dyeSlot, tintMask, targetLocation, targetSlot)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;dyeLocation : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Where the dye item is, as a &amp;lt;code&amp;gt;GameData.ItemLocs&amp;lt;/code&amp;gt; value.&lt;br /&gt;
;dyeSlot : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Slot of the dye item, starting at 1.&lt;br /&gt;
;tintMask : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Which colour of the target to change: 1 = primary, 2 = secondary, 3 = both (&amp;lt;code&amp;gt;GameData.TintMasks&amp;lt;/code&amp;gt; values; the stock UI passes the result of [[API:GetDyeTintMasks|GetDyeTintMasks]] or the tint picked in its dye window).&lt;br /&gt;
;targetLocation : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Must be &amp;lt;code&amp;gt;GameData.ItemLocs.EQUIPPED&amp;lt;/code&amp;gt;.&lt;br /&gt;
;targetSlot : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Equipment slot of the item to preview on.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Nothing.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* Nothing happens unless:&lt;br /&gt;
** &amp;lt;code&amp;gt;targetLocation&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;EQUIPPED&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;tintMask&amp;lt;/code&amp;gt; is not 0;&lt;br /&gt;
** the dye slot holds an item of type &amp;lt;code&amp;gt;GameData.ItemTypes.DYE&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The target starts from its current dye colours. The colour(s) selected by &amp;lt;code&amp;gt;tintMask&amp;lt;/code&amp;gt; are replaced by the dye&amp;#039;s colour. Any other &amp;lt;code&amp;gt;tintMask&amp;lt;/code&amp;gt; value leaves the colours as they are.&lt;br /&gt;
* A colour is only applied to a channel the item&amp;#039;s model supports (see [[API:GetDyeTintMasks|GetDyeTintMasks]]). Only armour slots take a preview.&lt;br /&gt;
* This is a preview in the client. It does not use up the dye. The stock UI calls [[API:RevertDyePreview|RevertDyePreview]] before it sends the real use request with [[API:SendUseItem|SendUseItem]].&lt;br /&gt;
* &amp;lt;code&amp;gt;GameData.ItemLocs.BANK&amp;lt;/code&amp;gt; is not supported for the dye&amp;#039;s location.&lt;br /&gt;
* If there is no player object, nothing happens.&lt;br /&gt;
* The function needs at least five arguments and only reads the last five.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
None besides the generic &amp;#039;&amp;#039;Invalid Parameters&amp;#039;&amp;#039; message when an argument is not a number.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
From &amp;lt;code&amp;gt;default/ea_modifyitem/source/useitemtargeting.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function UseItemTargeting.PreviewDye( tintMask )&lt;br /&gt;
    ...&lt;br /&gt;
    local sourceSlot = UseItemTargeting.TargetData.SourceSlot&lt;br /&gt;
    local sourceLoc = UseItemTargeting.TargetData.Source&lt;br /&gt;
    local targetLoc = UseItemTargeting.TargetData.TargetLoc&lt;br /&gt;
    local targetSlot = UseItemTargeting.TargetData.TargetSlot&lt;br /&gt;
&lt;br /&gt;
    DyePreview( sourceLoc, sourceSlot, tintMask, targetLoc, targetSlot )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:RevertDyePreview|RevertDyePreview]]&lt;br /&gt;
* [[API:DyeMerchantPreview|DyeMerchantPreview]]&lt;br /&gt;
* [[API:GetDyeTintMasks|GetDyeTintMasks]]&lt;br /&gt;
* [[API:CanUseDyeItem|CanUseDyeItem]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>