11 posts
Posted 17 August 2013 - 12:18 PM
Title: Help with Iron Tank Level showing on Monitor
I'm trying to get a monitor to show me the liquid level of an Iron Tank from Railcraft. I have a wired modem connected to it and have right clicked it and it says "Peripheral iron_tank_valve_0 connected". Now my only problem is getting a monitor to show the level. I don't know what commands I should give the computer to get it to show it. Can anyone help?
Also, I'm on FTB Unleashed v1.0.3
436 posts
Posted 17 August 2013 - 07:19 PM
… I wasn't entirely sure that worked. But, supposing it does, you can find out what functions a particular peripheral has by using the following:
m = peripheral.wrap(side or name) -- either the side of the computer, or the name of the remote peripheral, in this case "iron_tank_valve_0"
for k, v in pairs(m) do
print(k)
end
And that will print out what the peripheral can do (if anything).
11 posts
Posted 18 August 2013 - 07:48 PM
Thanks Omega. I did that and now it says:
getTanks
listMethods
32 posts
Location
UK
Posted 19 August 2013 - 04:08 AM
Now the next intuitive thing to try would be :
m = peripheral.wrap(side or name)
print(m.getTanks())
and see what it returns I think it returns a table so then try
m = peripheral.wrap(side or name)
tanksTable = m.getTanks("unknown")
maintank = tanksTable[1]
print(maintank.capacity)
print(maintank.amount)
and finally to print to monitor
m = peripheral.wrap("iron_tank_valve_0")
mon = peripheral.wrap("left")
-- loop so constantly updates
while true do
tanksTable = m.getTanks("unknown")
maintank = tanksTable[1] -- gets data for tank
-- prints all data to computer
shell.run('clear')
for k, v in pairs(maintank) do
print(tostring(k)..": "..tostring(v))
end
-- prints only capacity/amount to monitor
mon.clear() -- resets monitor
mon.setCursorPos(1,1)
mon.write("Capacity: "..maintank.capacity)
mon.setCursorPos(1,2)
mon.write("Amount: "..maintank.amount)
-- waits 5 seconds
sleep(5)
end
Edited on 19 August 2013 - 03:00 AM
11 posts
Posted 19 August 2013 - 07:32 AM
Thanks Last1Here, that worked a little. Now when I start that program it says:
startup:6: attempt to index ? (a nil value)
Is that line 6 where it says "unknown"? Sorry I'm trying to learn all the lua stuff.
32 posts
Location
UK
Posted 19 August 2013 - 08:14 AM
Thanks Last1Here, that worked a little. Now when I start that program it says:
startup:6: attempt to index ? (a nil value)
Is that line 6 where it says "unknown"? Sorry I'm trying to learn all the lua stuff.
worked fine for me
did you wrap the peripheral correctly? (make sure the modem on the tank is red)
2 posts
Location
Vienna
Posted 26 September 2013 - 05:46 PM
Is there any additonal Mod needed than RailCraft and ComputerCraft? I can't connect the Iron Tank to a CC Computer. The wired Modem doesn't get red and it doesn't say "Peripheral iron_tank_valve_0 connected". Do I have to do something special to connect them?
I'm thankful for every hint!
Kind regards,
Teralink
997 posts
Location
Wellington, New Zealand
Posted 27 September 2013 - 02:35 AM
Probably OpenPeripheral.
2 posts
Location
Vienna
Posted 27 September 2013 - 03:31 PM
Thanks, it works. =)
Here is the link, in case somebody needs it:
http://www.openperipheral.info/openperipheral/
1610 posts
Posted 27 September 2013 - 11:30 PM
If you ask me, I don't see why we have to use getTanks(side), I would much prefer a function like getData that simply returns a table wit the data… Why the double nesting?
Guess I'll have to make an API for that.
5 posts
Posted 28 September 2013 - 07:18 AM
If you ask me, I don't see why we have to use getTanks(side), I would much prefer a function like getData that simply returns a table wit the data… Why the double nesting?
Guess I'll have to make an API for that.
DO IT