ComputerCraft + Thaumic Tinkerer?

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Paxtrex

New Member
Jul 29, 2019
5
0
0
So i was trying to use the thaumic tinkerer peripehrals, but i cant get it to work! So what i'm asking is how can i make so that the computer reads the jar and print in a monitor the values of each jar? Why does when i do peripheral.wrap("jarname").getAspects() it returns a table value that's not the aspect name?
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Try looping through the table you get. With this code

Code:
local jar = peripheral.wrap(jarSide) -- jarSide is where the jar is e.g. "left"
local aspects = jar.getAspects()
for i,v in pairs(aspects) do
  write(i..": ")
  print(v)
end
 

Azzanine

New Member
Jul 29, 2019
2,706
-11
0
What version is Computercraft and does the jar have any essentia in it? In older versions if the jar was empty it wouldn't return a value. I think in newr version this has been remedied as CC will now detect labels.
 

Paxtrex

New Member
Jul 29, 2019
5
0
0
Try looping through the table you get. With this code

Code:
local jar = peripheral.wrap(jarSide) -- jarSide is where the jar is e.g. "left"
local aspects = jar.getAspects()
for i,v in pairs(aspects) do
  write(i..": ")
  print(v)
end

Man it didn't worked when i just copied and pasted the code(of course, editing the string), but i've modified it like this:
Code:
local jar = peripheral.wrap("tilejar_48") --the string is the name the peripheral proxy returns
local aspects = jar.getAspects()
for i,v in pairs(aspects) do
  write(i..": ")
  print(v)
end
And and it stills return a table vaule...
Also tried emptying the jar, but it just returns a table like a normal jar...
Don't know if helps, but here's my testing enviroment: http://prntscr.com/3p4vgr
And here is the message i get from computercraft(i've named the code you gave me teste3): http://prntscr.com/3p4vts
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
You can loop through that table too. Loop through any table with the for i,v in pairs(table) do ... end notation. (changing the names i and v is useful for each nested loop). For example

for i,v in pairs(supertable) do
for k,w in pairs(subtable) do
print(i)
print(k)
print(w)
end
end

I anticipated that you might get a table inside the table which is why I suggested this code

write(i..": ")
print(v)

instead of simply

print(i..": "..v)

which would have caused an" attempt to concatenate string and table" error
 
  • Like
Reactions: Paxtrex

Paxtrex

New Member
Jul 29, 2019
5
0
0
You can loop through that table too. Loop through any table with the for i,v in pairs(table) do ... end notation. (changing the names i and v is useful for each nested loop). For example

for i,v in pairs(supertable) do
for k,w in pairs(subtable) do
print(i)
print(k)
print(w)
end
end

I anticipated that you might get a table inside the table which is why I suggested this code

write(i..": ")
print(v)

instead of simply

print(i..": "..v)

which would have caused an" attempt to concatenate string and table" error

Dude sorry to ask again but how can i "translate"the table value to the name of the aspect in the jar? And why it returns a different table evem thought the aspect is the same? I checked out direwolf20'video and was wondering how he made so that it returns the aspect name (tried editing his code, got nothing)... Thxs for the answers btw!
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I don't know what the table structure for the aspects are so I can't be specific but here is the general principle.

If you want to refer to a specific value within a table you need to call the table name followed by the key name in square brackets. Here is an example.

Code:
local exampleTable = {
  [1] = "For",
  [2] = "the",
  [3] = "first",
  [4] = "time",
  [5] = "in", 
  [6] = "forever",
  }

local secondExample = {
  ["beautiful"] = "powerful",
  ["dangerous"] = "cold",
  }

print(exampleTable[1]) 
-->>>For

print(secondExample["beautiful"])
-->>>powerful

Key names and field values (the data stored inside the table) are all like normal variables and can be compared to one another, or have math etc operated on them (if they are numbers).

You can look through the table and find all the jars whose name equals "Praecantatio" and then add the aspect count (based on an assumption about how the table works). If you need any more help, then you will have to show me the code you are using in full. Another way to sort through a table and work out how its structured is like this

Code:
local newTable = {
  --table full of stuff
  }

newTable = textutils.serialize(newTable)

print(newTable)

serialize turns the table into a big long string that can be hard for a person to read but has other uses. If you are having trouble still, print screening that string (or saving it to a file and copying it here if you know how) might be useful.
 

Paxtrex

New Member
Jul 29, 2019
5
0
0
I've tried doing something like
Code:
local jar = peripheral.wrap("tilejar_48")
local aspectName = jar.getAspects()
local aspectTable = {aspectName[name]}
print(aspectTable)
and it returns nothing, just like if i did print().
Anyways here is the array that textutils.serialize() returned me : http://prntscr.com/3q31zr
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I've tried doing something like
Code:
local jar = peripheral.wrap("tilejar_48")
local aspectName = jar.getAspects()
local aspectTable = {aspectName[name]}
print(aspectTable)
and it returns nothing, just like if i did print().
Anyways here is the array that textutils.serialize() returned me : http://prntscr.com/3q31zr
write

Code:
local jar = peripheral.wrap("tileJar")
local aspect = jar.getAspects() -- A function can return a table without you having to wrap it in a table like, {jar.getAspects()} etc. {aspectName[name]} is probably the same as {"Perfodio"}

and then either

Code:
print(aspect["name"]) -- the quotation marks inside the key is important because the keyname is a string

or (if the above doesn't work, something like this)

Code:
print(aspect[1]["name"]) -- no quotation marks necessary for the 1 because it is a number
 

Paxtrex

New Member
Jul 29, 2019
5
0
0
write

Code:
local jar = peripheral.wrap("tileJar")
local aspect = jar.getAspects() -- A function can return a table without you having to wrap it in a table like, {jar.getAspects()} etc. {aspectName[name]} is probably the same as {"Perfodio"}

and then either

Code:
print(aspect["name"]) -- the quotation marks inside the key is important because the keyname is a string

or (if the above doesn't work, something like this)

Code:
print(aspect[1]["name"]) -- no quotation marks necessary for the 1 because it is a number

It worked now, the thing is that it's an array inside an array, that's what confused me, thanks man! (also the missing quotes there was a typo, sorry!)