這裏是我的一段代碼蒸汽Tf2的貿易BOT Node.js加載問題
// Any time an item changes in the trade window
trade.on('offerChanged', function(itemAdded, item) {
if (itemAdded) {
logger.info('User added: '+item.name)
if (item.name == 'Festive Black Box') {
trade.chatMsg('Cool!');
trade.addItem('Scrap Metal');
}
}
所以,基本上我的兄弟放了這個項目(節日黑匣子),它應該把一個廢料,但它不,而是說「酷!」 (所以我知道它的工作原理),並沒有插入廢料的機器人,我等了很長時間,似乎沒有工作,也只有一個廢金屬在我的庫存!
這裏有一些我的代碼片段;
// After we accept the trade, we deal with the trade session
client.on('sessionStart', function(steamID) {
inTrade = true;
client.setPersonaState(steam.EPersonaState.Busy);
trade.open(steamID, function() { // Pass the trade off to our steam-trade library
trade.loadInventory(appid.TF2, contextid.TF2, function(inv) {
inventory = inv;
scrap = inv.filter(function(item) { return item.name == 'Scrap Metal';});
logger.error(scrap)
if (!inv) {
logger.error('Error getting own inventory. Cancelling trade.');
client.sendMessage(steamID, 'Could not load my inventory, please contact my creator.');
trade.cancel(steamID);
} else {
logger.debug('Found '+inv.length+' items in my inventory.');
myBackpack = inv; // Now we can access it globally
// If you want to put items up in the trade window immediately,
// here is where you could do it. Instead we're calling a custom function.
onTradeStart(steamID); // Our custom function
}
});
});
});
你有沒有登錄'item.name'? – 2015-04-02 17:21:55
不,我不知道它到底是什麼,也許'Scrap Metal'item.name? – EEVV 2015-04-02 17:29:50
@TomA請舉例? – EEVV 2015-04-02 17:31:20