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

p.getAspects showing as a table replay

Started by slayerscout, 15 July 2014 - 06:10 PM
slayerscout #1
Posted 15 July 2014 - 08:10 PM
Hi all,

For the last couple of hour i've been trying to get a computer to show what aspect name is in the jar.

So in lua I would call the below:

p = periphereal.wrap("tilejar_25")
p.getAspects()

The reply from that warded jar is
table: 1e482c5a
which contains Metallum


and this is the same for void jars
table: 1b1754c1
which contains Mortuus



I ask as I'm trying to build the essentia system that Direwolf20 buit in S6 E74 of his Lets Play (Youtube)
I am currently using the Direwolf20 (v1.0.23) 1.6.4 pack

Any help would welcomed
Many thanks in advance.
KingofGamesYami #2
Posted 15 July 2014 - 09:58 PM
It would help if you knew what was in the table.

p = peripheral.wrap( "tilejar_25" )
for k, v in pairs( p.getAspects() ) do
 print( k )
end
hilburn #3
Posted 15 July 2014 - 11:30 PM
IIRC Jars, like most tanks have an implementation along the lines of

fluids = {[fluid1]={fluidname, fluid volume, fluidID}, [fluid2]=...}
so as Yami says loop through them but you'll probably have to serialize the output
slayerscout #4
Posted 17 July 2014 - 03:12 PM
It would help if you knew what was in the table.

p = peripheral.wrap( "tilejar_25" )
for k, v in pairs( p.getAspects() ) do
print( k )
end
HI Yami,
This just returns 1 for every 51 void jars

IIRC Jars, like most tanks have an implementation along the lines of

fluids = {[fluid1]={fluidname, fluid volume, fluidID}, [fluid2]=...}
so as Yami says loop through them but you'll probably have to serialize the output

what would be the best way of doing this as I'm using a edited version of direwolf20 aspects code from pastebin (link).

I've edited (pastebin code) it to show the informatio on a remote screen and i've also edited line 28 for the right jar information and still no information shows on the screens.


function scanEssentia()
  for i,j in ipairs(jars) do
	 if peripheral.getType(j) == "tilejarvoid_" then
	   asp = peripheral.call(j, "getAspects")
	   countasp = peripheral.call(j, "getAspectCount", asp)
	   if countasp > 0 then
		  essentia[asp] = math.floor(countasp)
	   end
--	   print(countasp)
--	 print(asp..":"..countasp)
--	 print(peripheral.getType(j))
	 end
  end
end
hilburn #5
Posted 17 July 2014 - 04:14 PM
Just tested this quickly and firstly I was completely wrong, works nothing like normal tanks, so disregard my previous suggestion.

Secondly, the reason yours is not working is that both warded jars and void jars have a peripheral type of "tt_aspectContainer", so I don't know where the "tilejarvoid_" came from but that is incorrect
theoriginalbit #6
Posted 17 July 2014 - 04:39 PM
Not to mention that there isn't the _ at the end of the peripheral type; when you're looking for the type, you take the number and it's preceding _ off the peripheral name.