API:SetPlayerVariation
From RoR Wiki
UI Lua API · Appearance functions
Version: WAR 1.4.8
Shows the player character with the appearance that a marketing reward item in the inventory would give, without applying it.
SetPlayerVariation(slot)
Arguments
- slot
number– Inventory slot of the item, as used to indexDataUtils.GetItems(). The stock UI passesCursor.Data.SourceSlotfor an item picked up from the inventory.
Returns
Nothing.
Details
- Nothing happens unless the slot holds an item whose type is
GameData.ItemTypes.MARKETING. - The item carries an appearance slot number and a variation value. The client writes that value into the player's appearance data for that slot (only for slot numbers below 15) and updates the character's look.
- This is a local preview only. Nothing is sent to the server. Use ApplyPlayerVariation to apply the item, or RevertPlayerVariation to undo the preview.
- The client remembers the slot and its previous value for RevertPlayerVariation. Only one previous value is kept, so a second call replaces it.
- The function returns nothing if there is no player.
Errors
None besides the generic Invalid Parameters message when the argument is not a number.
Example
From ea_characterwindow/source/characterwindow.lua, when a marketing item is dropped on the character window:
local itemData = DataUtils.GetItems()[Cursor.Data.SourceSlot]
if( Cursor.Data.Source == Cursor.SOURCE_INVENTORY and itemData.type == GameData.ItemTypes.MARKETING) then
local slot = Cursor.Data.SourceSlot
CharacterWindow.marketItemData = itemData
CharacterWindow.marketItemDataSlot = slot
-- ...
SetPlayerVariation(slot)
