这是我的代码的一个例子
inv = peripheral.wrap("right")
var1 = inv.getAllStacks()
var2 = var1[1] --This should set var2 to another table
print(var2[1])当我在一台高级计算机上执行这个程序时,它旁边有一个钻石箱,里面有东西,它根本不打印任何东西。请帮我解决这个问题!
发布于 2014-05-21 20:08:52
解决: getAllStacks()方法所做的是返回一个充满字典的表。因此,要在堆栈1中获取项的名称,您可以这样做:
chest = peripheral.wrap("right")
chestInv = chest.getAllStacks()
item1 = chestInv[1]
print(item1["name"]) --Because name is the term and the value is the name of the item.这上面的代码将打印项目的名称,在第一个槽的胸部。
发布于 2017-01-19 19:25:23
使用一个插件(AddonCCPeripherals),并将您的胸部连接到计算机(与代理)!现在您必须编码:
chest = peripheral.wrap("diamond_0")
Diamond chest: "diamond_0"
Iron chest: "iron_0"(对不起,我的文字中有错误,我来自德国,但代码是正确的)
https://stackoverflow.com/questions/23691009
复制相似问题