Jump to content




Help with Iron Tank Level showing on Monitor


  • You cannot reply to this topic
10 replies to this topic

#1 Epoch86

  • Members
  • 11 posts

Posted 17 August 2013 - 11:18 AM

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

#2 OmegaVest

  • Members
  • 436 posts

Posted 17 August 2013 - 06: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).

#3 Epoch86

  • Members
  • 11 posts

Posted 18 August 2013 - 06:48 PM

Thanks Omega. I did that and now it says:

getTanks
listMethods

#4 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 03: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 by Last1Here, 19 August 2013 - 04:00 AM.


#5 Epoch86

  • Members
  • 11 posts

Posted 19 August 2013 - 06: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.

#6 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 07:14 AM

View PostEpoch86, on 19 August 2013 - 06:32 AM, said:

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

Posted Image
did you wrap the peripheral correctly? (make sure the modem on the tank is red)

#7 Teralink

  • New Members
  • 2 posts
  • LocationVienna

Posted 26 September 2013 - 04: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

#8 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 27 September 2013 - 01:35 AM

Probably OpenPeripheral.

#9 Teralink

  • New Members
  • 2 posts
  • LocationVienna

Posted 27 September 2013 - 02:31 PM

Thanks, it works. =)

Here is the link, in case somebody needs it: http://www.openperip...openperipheral/

#10 apemanzilla

  • Members
  • 1,421 posts

Posted 27 September 2013 - 10: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.

#11 MAYUYU

  • Members
  • 5 posts

Posted 28 September 2013 - 06:18 AM

View PostApemanzilla, on 27 September 2013 - 10:30 PM, said:

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





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users