This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MayContainVennom's profile picture

[Open Blocks] [Open Peripherals] getTankInfo being seen as a string and not a table

Started by MayContainVennom, 22 January 2014 - 01:29 PM
MayContainVennom #1
Posted 22 January 2014 - 02:29 PM
Hello there,

I'm currently trying to make a program to read how much Liquid XP I have in a tank. To start off with I did some research and found out that I need to use getTankInfo to pull the information and it will be brought down in a table. I've never really used tables before so went looking for some templates to get me started. all the ones I have found seem to be throwing up an error saying "bad argument: table expected, got string"

The code I'm trying to use now:
local tank = peripheral.wrap("back")
local tableInfo = tank.getTankInfo("south")
for k, v in pairs(tableInfo) do
  for x, y in pairs(v) do
   print(x .. ": " .. y)
  end
end

It was found somwhere in the OpenBlocks thread and seemed to be working for the person who posted it. I cannot work out why this isnt returning a table when tableinfo is one.

Thanks for reading…
Vennom
CometWolf #2
Posted 22 January 2014 - 02:41 PM
tableInfo probably is, however the valuta held by the table (v) might not be. Running it through a pairs iterator will therefore give the error.
MayContainVennom #3
Posted 22 January 2014 - 02:46 PM
tableInfo probably is, however the valuta held by the table (v) might not be. Running it through a pairs iterator will therefore give the error.

So were would I replace V to make it work?
CometWolf #4
Posted 22 January 2014 - 02:59 PM
Remove the second loop and replace x with k, and y with v in the print
Edited on 22 January 2014 - 02:01 PM
MayContainVennom #5
Posted 22 January 2014 - 03:03 PM
This is now producing:


I've had this output before and is no use to me… Were as what I was using before the post before had the actually values being produced
Lyqyd #6
Posted 22 January 2014 - 03:04 PM
What version of OpenP are you using? You likely need to update.
MayContainVennom #7
Posted 22 January 2014 - 03:06 PM
0.2.1-preview8
Edited on 22 January 2014 - 02:06 PM
Lyqyd #8
Posted 22 January 2014 - 05:07 PM
You need to update. Some more recent versions do not have that problem.