Jump to content




Pulling value out of table



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

#1 XLT_Frank

  • Members
  • 6 posts

Posted 09 May 2014 - 07:14 PM

So I found this pastbin code from a thread on this forum: http://pastebin.com/qzwqx84r

It no longer works because it uses an old version of getTanks instead of getTankInfo. I am trying to revise it.

I created the following program to understand how the table works:
local valve = peripheral.wrap("bottom")
local tank = valve.getTankInfo("bottom")
for key, value in pairs(tank) do
  print(key .. " = " .. tostring(value))
  for a,b in pairs(value) do
	print(a.." "..B)/>/>
  end
end

It produces:
1 = table: 2aa0101
rawName Water
amount 5600000
capacity 5600000
name water
id 1

That pastebin code has the following:
local function tankStats(tank)
		if(tank) then
				local amt = tank["amount"]
				local size = tank["capacity"]
				local filled = (amt and 1 / (size / amt)) or 0
				return amt, size, filled
		else
				return nil;
		end
end
and
local kind = tank["name"]

How do I get the information into that format appropriately? Obviously I will need to change:
			local tank = valve.getTanks("back")[1]
to
			local tank = valve.getTankInfo("back")[1]

I don't think the

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 May 2014 - 08:37 PM

Moved to Ask a Pro.

#3 blipman17

  • Members
  • 92 posts

Posted 10 May 2014 - 05:56 AM

This might help.
http://www.computerc...nd-not-a-table/

#4 XLT_Frank

  • Members
  • 6 posts

Posted 10 May 2014 - 05:35 PM

This is OBE. I didn't see someone's contribution to the following thread: http://www.computerc...ng/page__st__60 that fixed a lot of the problem.s





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users