API:SendUseItem
From RoR Wiki
UI Lua API · Item functions
Version: WAR 1.4.8
Asks the server to use an item, optionally on another item.
SendUseItem(location, slot, option, targetLocation, targetSlot)
Arguments
- location
number– Where the item is, as aGameData.ItemLocsvalue.- slot
number– Slot of the item inlocation, starting at 1.- option
number– Extra choice sent with the request, as a single byte. The stock UI passes 0, the 0-based index of a "use option" picked in a dialog, or an ability value for targeted uses.- targetLocation
number– Location of the target item, or 0 for no target.- targetSlot
number– Slot of the target item, or 0 for no target.
Returns
Nothing.
Details
- Supported locations are
EQUIPPED,INVENTORY,QUEST_ITEM,INVENTORY_OVERFLOW,CRAFTING_ITEMandCURRENCY_ITEM. For any other location, includingBANK, nothing is sent. - The target is converted the same way. An unsupported or 0 target location is sent as "no target".
- The client does not check that the slot holds an item, or that the item can be used. The server decides.
- If there is no player object, nothing happens.
- The function needs at least five arguments and only reads the last five.
Errors
None besides the generic Invalid Parameters message when an argument is not a number.
Example
Using an item from the backpack, from default/ea_backpackwindow/source/backpackutils.lua:
if not ItemUtils.ShowUseOptions(itemData, GameData.ItemLocs.INVENTORY, slot)
then
SendUseItem( GameData.ItemLocs.INVENTORY, slot, 0, 0, 0 )
end
Using an item on another item, from default/ea_modifyitem/source/useitemtargeting.lua:
SendUseItem(sourceLoc, sourceSlot, ability, targetLoc, targetSlot)
