Computercraft, Liquids, and Direwolf20?

  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

SnowsongWolf

New Member
Jul 29, 2019
15
0
0
So I'm wracking my brain over this. Is there any way to get liquid info into a computer in DW20 1.6.4? Without RichardG in the mix I can't find any mix of blocks that will do what the Nuclear Information Reader and a liquid sensor card used to do. And because I'm hosting a server for a community, adding MiscPeripherals in would not be a painless process.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I am pretty sure that Direwolf20 has open peripherals in it. While you can't put liquid directly into a computer using it, you can wrap a tank as a peripheral. I don't know about how extensive the support is in 1.6 because I believe Mikeymoo is redoing a lot of it, but in 1.5 you could read at least, railcraft tanks (so long as you are wrapping the valve block) and buildcraft tanks as well as the internal tanks of a lot of machines. It could probably do more than that too.

Try wrapping a tank and use the getTanks(side string) function on it. It should return a table that gives some data about the tank. The table structure isn't documented so you might have to experiment with a few generic for loops to get all the data that you want.
 

SnowsongWolf

New Member
Jul 29, 2019
15
0
0
Unfortunately it's not working. The command is getTankInfo(side) and it's returning a string with what I assume is a table address at the end of it.

Code:
term.clear()
term.setCursorPos(1,1)
local tank = peripheral.wrap("back")
local dirs ={"north","south","east","west","up","down","unknown"}
for _, side in pairs(dirs)do
  print(side..": "..tostring(tank.getTankInfo(side)))
end
print("")
unkTank = tank.getTankInfo("unknown")
for i,v in pairs(unkTank)do
  print(i..": "..tostring(v))
end
gives me:
Code:
north: table:494fded9
south: table:7fb8a36e
east: table:20999e7d
west: table:4f4e4954
up: table:7bf694a5
down: table:330b9d3f
unknown: table:18f030e3
1: net.minecraftforge.fluids.FluidTankInfo@411993df

EDIT

And it's doing that with both BC tanks and Railcraft ones.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
It is a nested table. You will need to do something like this

Code:
local tankData = thatFunction
for i,v in pairs(tankData) do
  for k,w in pairs(v) do
    --stuff
  end
end

It has been awhile since I did it so I don't completely remember how the table is structured, like I said some experimentation is required.

The reason you have the nested tables is so it can work on blocks that have more than one tank inside, like a combustion engine.

I think that the keys in the supertable are numeric values. Then in the nested tables you have string keys that describe the data like Liquid type, amount, capacity etc.
 

SnowsongWolf

New Member
Jul 29, 2019
15
0
0
No see I tried something very similar to that before and the for k,w line (x,y in my case) I get an error table expected, got string. It's not a nested table, it's actually that string value I listed. You'll notice for the other tostring values it lists them as table: address but not for the last one.

My original code was based on the listOilTank function at http://pastebin.com/WVLZjAC2 and that's where I found out it's passing a string instead of the actual nested table.