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

[Question] Print taable in a table

Started by Wolvan, 06 April 2012 - 11:32 PM
Wolvan #1
Posted 07 April 2012 - 01:32 AM
I have the following problem ( and yes I tried myself ). I never used tables before and now I need to know:
Is it possible to print a table in a table?

I have this

for k,v in pairs(ServerID) do
print("["..tostring(k).."]S_IP: "..tostring(v))
end
And I have a second table called serverNames
Now i want to print the servername table instead the ServerID Table but still keep the ID values in use So If I type for example 1 it uses the 1. entry of table ServerID but on screen [1]Test-Server is written.

Sry if my language is a mess I'm german ;P
Advert #2
Posted 07 April 2012 - 02:11 AM
You can use k on the ServerNames table.


print("S_Name:", ServerNames[k])
Wolvan #3
Posted 07 April 2012 - 11:38 AM
You can use k on the ServerNames table.


print("S_Name:", ServerNames[k])
Yes I know but I want to get the ID if I type for example 1
Is it possible to remove the for loop and just do

k,v in pairs(ServerID)
else I think if found a walkaround