diff --git a/runner_functions.js b/runner_functions.js index efd776e..50d10b5 100644 --- a/runner_functions.js +++ b/runner_functions.js @@ -137,25 +137,30 @@ function bank_withdraw(gold) parent.socket.emit("bank",{operation:"withdraw",amount:gold}); } -function bank_store(num,pack,pack_slot) +/** + * Store an item in the Bank. + * + * `bank_store(0)` - Stores the first item in inventory in the first/best spot in bank. + * `bank_store(0, "items0", 41)` - Stores the first item in inventory in the last spot in "items0". + * + * @param {number} inventory_slot Inventory slot number (0-41). + * @param {string} [pack] Bank pack (one of "items0"-"items7"). + * @param {number} [pack_slot=-1] Pack slot number (0-41; default: first available). + */ +function bank_store(inventory_slot, pack, pack_slot) { - // bank_store(0) - Stores the first item in inventory in the first/best spot in bank - // parent.socket.emit("bank",{operation:"swap",pack:pack,str:num,inv:num}); - // Above call can be used manually to pull items, swap items and so on - str is from 0 to 41, it's the storage slot # - // parent.socket.emit("bank",{operation:"swap",pack:pack,str:num,inv:-1}); <- this call would pull an item to the first inventory slot available - // pack is one of ["items0","items1","items2","items3","items4","items5","items6","items7"] if(!character.bank) return game_log("Not inside the bank"); - if(!character.items[num]) return game_log("No item in that spot"); - if(!pack_slot) pack_slot=-1; // the server interprets -1 as first slot available + if(!character.items[inventory_slot]) return game_log("No item in that spot"); + if(!(pack_slot >= 0)) pack_slot=-1; // the server interprets -1 as first slot available if(!pack) { - var cp=undefined,cs=undefined; + var cp=undefined; for(var cpack in bank_packs) { if(pack || bank_packs[cpack][0]!=character.map || !character.bank[cpack]) continue; - for(var i=0;i<42;i++) + for(var i=0;i=0)) inventory_slot=-1; // the server interprets -1 as first slot available + + parent.socket.emit("bank",{operation:"swap",pack:pack,str:pack_slot,inv:inventory_slot}); } function swap(a,b) // inventory move/swap