12,883
edits
m (Update the currency object names) |
(→Remove Item from Bank: Document solution for removing items with invalid quantities) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 24: | Line 24: | ||
| logLost || boolean || Yes || false || If <code>true</code>, items that did not fit into the bank will be logged as lost | | logLost || boolean || Yes || false || If <code>true</code>, items that did not fit into the bank will be logged as lost | ||
|- | |- | ||
| found || boolean || Yes || false || Determines if | | found || boolean || Yes || false || Determines if items added by this function will be included within the "Times Found" statistic for that item within the completion log. Therefore, unless this parameter is set to <code>true</code>, any items added in this way will not contribute towards the player's item completion percentage. | ||
<br/><br/>{{Disclaimer|'''Note:''' When adding {{ItemIcon|Bank Slot Token|Bank Slot Tokens}}, it is suggested that this parameter is set to <code>true</code>, otherwise this may cause issues with the way the game calculates the amount of bank space a player has.}} | |||
|- | |- | ||
| ignoreSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full | | ignoreSpace || boolean || Yes || false || If <code>true</code>, the item will be added to the bank even if the bank is already full | ||
Line 36: | Line 37: | ||
The removeItemQuantityByID function can be used to remove any item from the bank | The removeItemQuantityByID function can be used to remove any item from the bank | ||
<syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight> | <syntaxhighlight lang="js">game.bank.removeItemQuantityByID(itemID, quantity, removeItemCharges)</syntaxhighlight> | ||
Note that if an item's quantity is in an invalid state, such as <syntaxhighlight lang="js" inline>NaN</syntaxhighlight> or <syntaxhighlight lang="js" inline>Infinity</syntaxhighlight>, then this function will not be able to remove that item from the bank. For any such items, use the below snippet instead: | |||
{{SpoilerBox | |||
|color=default | |||
|title=Code | |||
|text=First, enter the below into the console: | |||
<syntaxhighlight lang="js">function removeItemByID(itemID) { | |||
const item = game.items.getObjectByID(itemID); | |||
if (item === undefined) | |||
throw new Error( | |||
`Error removing item from bank by id. Item with id: ${ itemID } is not registered.` | |||
); | |||
const bankItem = game.bank.items.get(item); | |||
if (bankItem === undefined) | |||
throw new Error( | |||
`Tried to remove quantity from bank, but item is not in bank.` | |||
); | |||
bankItem.quantity = 1; | |||
game.bank.removeItemQuantity(item, 1, true); | |||
}</syntaxhighlight> | |||
After this, invoke the newly-created function with the appropriate item ID to remove items from the bank. For example: <syntaxhighlight lang="js" inline>removeItemByID('melvorD:Oak_Logs');</syntaxhighlight> | |||
}} | |||
=== Attributes === | === Attributes === | ||
Line 50: | Line 73: | ||
=== Examples === | === Examples === | ||
<syntaxhighlight lang="js">game.bank.removeItemQuantityByID( | <syntaxhighlight lang="js">game.bank.removeItemQuantityByID('melvorD:Oak_Logs', 10);</syntaxhighlight> | ||
The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank. | The above code will result in 10 {{ItemIcon|Oak Logs}} being removed from the bank. | ||
Line 88: | Line 111: | ||
==== Examples ==== | ==== Examples ==== | ||
<syntaxhighlight lang="js">game. | <syntaxhighlight lang="js">game.raidCoins.remove(1);</syntaxhighlight> | ||
The above code will remove 1 [[Raid Coins|Raid Coin]] from the player. | The above code will remove 1 [[Raid Coins|Raid Coin]] from the player. | ||
Line 104: | Line 127: | ||
==== Examples ==== | ==== Examples ==== | ||
<syntaxhighlight lang="js">game. | <syntaxhighlight lang="js">game.slayerCoins.set(999);</syntaxhighlight> | ||
The above code will set the player's [[Raid Coins|Raid Coin]] balance to 999, regardless of what the previous balance of raid coins owned was. | The above code will set the player's [[Raid Coins|Raid Coin]] balance to 999, regardless of what the previous balance of raid coins owned was. | ||