4 posts
Posted 16 November 2013 - 10:07 AM
Hi.
Im new here and i dont know if this is the right place to ask.
I made myself a program getting info from tanks, and then doing stuff depending on the info. All worked fine, but because i had so many tanks, i wanted to use liquid managers instead (lesser lag).
And with the sensorview program i could see that it was possible to get info from it, but when i tried like a normal tank i keep getting error nil value.
I hope someone can help me out.
Kind regards
Fyrst_Igor
8543 posts
Posted 16 November 2013 - 02:47 PM
Please post your code and a screenshot of sensorview with the liquid manager info showing.
4 posts
Posted 16 November 2013 - 05:04 PM
I solved my problem and found a way to get the info i wanted. In the meantime, i learned that openCCsensor was discontinued, so wanted to switch to using modem instead. After some time, and trying i managed to pull out the info from the liquid manager, but it comes like this:
1 = table: (random numbers and letters)
2 = table: (random numbers and letters)
3 = table: (random numbers and letters)
4 = table: (random numbers and letters)
dat makes sence, since the liquid manager got 4 internal tanks. But how to unscramle the tables ? so that i can get capacity and amount out, like i used to from the openccsensor.
my code is:
local tank1 = peripheral.wrap("liquid_manager_6")
local table = tank1.getTanks("back")
for key, value in pairs(table) do
print(key.." = "..tostring(value))
end
8543 posts
Posted 16 November 2013 - 05:56 PM
Well, you've got to look up specific indexes in the tables, or iterate through them like your for loop is doing with pairs(). Don't call tables "table", by the way. This should print the amount of liquid and the total capacity for each tank.
local tank1 = peripheral.wrap("liquid_manager_6")
local tanks = tank1.getTanks("back")
for tankNum, tankInfo in pairs(tanks) do
print(tankNum..":")
print(tankInfo.amount)
print(tankInfo.capacity)
end
4 posts
Posted 16 November 2013 - 08:07 PM
Ty alot for ur help, and getting it so fast :)/> I got it all working again, and no longer uses the buggy sensors.
8543 posts
Posted 16 November 2013 - 08:14 PM
Also, OpenCCSensors hasn't been discontinued, it's simply been dormant. I'm actually in the process of getting it updated to 1.6.4 currently.
4 posts
Posted 17 November 2013 - 09:16 AM
Ohh. I went on IRC and asked, they told me it was discontinued. But im glad to hear an update is comming, it does make things easier. But now i atleast know how to do it both wired and wireless so i did learn something :D/>