Posted 06 March 2015 - 11:41 AM
Spent longer than I want to admit trying to get the getTankInfo() method to work and after finding a solution I wanted to share it here in case it could be of use to anyone else. Im my particular case I wanted to use it with drums, as they have a great look, but I tested with drums and Railcraft tanks.
The best existing code I could find that almost worked is here http://pastebin.com/QRq31g0z taken from this r/feedthebeast post http://www.reddit.co...nts_of_an_iron/
Since that was made there seems to have been a change in how the method works, or else I just ran into some bizarre issue unique to FTB Infinity 1.2.0.
Changes were shown in red here. (Except the CODE tag has defeated me) If you uncomment the code to serialize the table you can see that everything but capacity is stored under [1]["contents"]["name"/"amount"/"rawName"/etc]. In the resources I could find it seems that it was previously all available in the table under [1]["name"/"amount"/"rawName"/etc].
I hope this can be of help to some of you.
Thank you to IYOKAY for the code and henx125 for the Reddit post.
The best existing code I could find that almost worked is here http://pastebin.com/QRq31g0z taken from this r/feedthebeast post http://www.reddit.co...nts_of_an_iron/
Since that was made there seems to have been a change in how the method works, or else I just ran into some bizarre issue unique to FTB Infinity 1.2.0.
Changes were shown in red here. (Except the CODE tag has defeated me) If you uncomment the code to serialize the table you can see that everything but capacity is stored under [1]["contents"]["name"/"amount"/"rawName"/etc]. In the resources I could find it seems that it was previously all available in the table under [1]["name"/"amount"/"rawName"/etc].
I hope this can be of help to some of you.
--Computer must be touching valve
--Enjoy!
local tank = peripheral.wrap("CHANGE TO SIDE TANK IS ON")
local info = tank.getTankInfo("CHANGE TO SIDE TANK IS ON")
-- prints information >> print(textutils.serialize(info))
print(info[1]["contents"]["amount"])
while true do
info = tank.getTankInfo("CHANGE TO SIDE TANK IS ON")
if info[1]["contents"]["amount"] == info[1]["capacity"] then
rs.setOutput("CHANGE TO SIDE REDSTONE WILL OUTPUT", true)
else
rs.setOutput("CHANGE TO SIDE REDSTONE WILL OUTPUT", false)
end
sleep(5)
end
Thank you to IYOKAY for the code and henx125 for the Reddit post.
Edited on 06 March 2015 - 10:43 AM