2 posts
Posted 07 December 2013 - 01:02 PM
Hi, I would like to write a program that prints a mekanism dynamic tank level onto a monitor but I can't figure out how to get the thing to read the tank level. First of all, what item(s) should I use, and second of all, what would my code look like?
Thanks in advance
7508 posts
Location
Australia
Posted 07 December 2013 - 07:28 PM
Currently it depends on whether or not the Mekanism developer has added support for tank information. If he hasn't, but you've got OpenPeripheral installed, then that
should pick up that it's a tank (if the dev made it right).
In either case you'd need to connect the computer to the tank in any of the ways ComputerCraft gives us, be it network cables, or sitting it directly beside it.
Once you've done that inspect the interaction you have available to you with
for i,v in ipairs(peripheral.getMethods("[side or name]") do
print(v)
end
making sure to replace [side or name] with the side of the computer the tank is on, or the name of the tank on the network.this will output various different methods you can call on the tank using
peripheral.call, one of these (if there is support) should get you the tanks information.
2 posts
Posted 08 December 2013 - 11:22 AM
Currently it depends on whether or not the Mekanism developer has added support for tank information. If he hasn't, but you've got OpenPeripheral installed, then that
should pick up that it's a tank (if the dev made it right).
In either case you'd need to connect the computer to the tank in any of the ways ComputerCraft gives us, be it network cables, or sitting it directly beside it.
Once you've done that inspect the interaction you have available to you with
for i,v in ipairs(peripheral.getMethods("[side or name]") do
print(v)
end
making sure to replace [side or name] with the side of the computer the tank is on, or the name of the tank on the network.this will output various different methods you can call on the tank using
peripheral.call, one of these (if there is support) should get you the tanks information.
Perfect. I get:
listMethods
getInvName
getStackInSlot
getSizeInventory
I'm assuming that I should be using getSizeInventory. Do I still have to use peripheral.wrap()?
7508 posts
Location
Australia
Posted 08 December 2013 - 05:37 PM
Perfect. I get:
listMethods
getInvName
getStackInSlot
getSizeInventory
I'm assuming that I should be using getSizeInventory.
If they're all you're getting that means two things
- The Mekanism developer hasn't added ComputerCraft support for that block, and OpenPeripheral is picking it up instead
- The Mekanism developer hasn't implemented the tank correct and it means that OpenPeripheral only sees it as an inventory, not a tank
It has been requested before that we add Mekanism support into OpenPeripheral (beyond the auto-add stuff), however I'm still under the belief that we shouldn't incase the Mekanism dev wishes to add extra support in later, which may cause collisions, and/or problems with peoples scripts… As such it means that I suggest you put a request forward to the Mekanism dev to add in this support.
If OpenPeripheral saw it as a tank with liquids it would provide you with the function
getTankInfo.
Do I still have to use peripheral.wrap()?
Yes, or you could use
peripheral.call there's always (as the saying goes) two ways to skin a cat.
When you use
peripheral.wrap, it actually does the
peripheral.call on the peripheral, meaning that this
local chest = peripheral.wrap("chest")
print(chest.getInvName())
and this
print(peripheral.call("chest", "getInvName"))
pretty much the same
Edited on 08 December 2013 - 04:37 PM