Posted 13 April 2016 - 09:58 PM
What I need help with specifically, is getting the amount of items stored inside of a Factorization barrel. Now, I've have had limited success so far. I can print all the information out that I need and see that the value I want is there, I just cannot for the life of me figure out how to access it!
Here is my code that I am using the get the information of the barrel.
Edit: It seems to want to add in the "/>"s, which is annoying. Please ignore those and read all B's and b's.
Now, what I get at the end of this is:
I just included in there the values that get printed from "i", all the others are pairs from "j".
Now, from my limited understanding of LUA (I'm more used to Java or JavaScript), the table should look something like this…
The value I want to access, is in the second table, the "qty" that equals 1. That is the actual value of how many logs I have stored inside this barrel. I don't know how to access it, and quite frankly I am VERY frustrated with this at the moment! A big thanks in advance to anyone who can help me out!
Here is my code that I am using the get the information of the barrel.
local bar = peripheral.wrap("right")
local tableInf = bar.getAllStacks()
for i, j in pairs(tableInf) do
print(i)
for a, b in pairs(j) do
-- print(a)
if (type(B)/>/>) ~= "table") then
print(a..": "..B)/>/>
--[[ else
for c, d in pairs(B)/>/> do
print(c..": "..d)
end--]]
end
end
end
Edit: It seems to want to add in the "/>"s, which is annoying. Please ignore those and read all B's and b's.
Now, what I get at the end of this is:
1 (this comes from printing "i")
id: 17
name: Oak Wood
rawName: tile.log.oak
dmg: 0
maxSize: 64
qty: 0
2 (this comes from printing "i")
id: 17
name: Oak Wood
rawName: tile.log.oak
dmg: 0
maxSize: 64
qty: 1
I just included in there the values that get printed from "i", all the others are pairs from "j".
Now, from my limited understanding of LUA (I'm more used to Java or JavaScript), the table should look something like this…
tableInf = {
["1"] = {
id
name
rawName
dmg
maxSize
qty
}
["2"] = {
id
name
rawName
dmg
maxSize
qty
}
}
The value I want to access, is in the second table, the "qty" that equals 1. That is the actual value of how many logs I have stored inside this barrel. I don't know how to access it, and quite frankly I am VERY frustrated with this at the moment! A big thanks in advance to anyone who can help me out!
Edited on 13 April 2016 - 08:01 PM