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

Lua [help please]

Started by predatorxil, 22 October 2012 - 01:37 PM
predatorxil #1
Posted 22 October 2012 - 03:37 PM
Im trying to print my table of user so i dont have to type them out. anything will help, all i want is to print wahts in the table, such as users
Ditto8353 #2
Posted 22 October 2012 - 03:50 PM
If you just want one user per line, it's pretty simple:

for i,v in ipairs(userTable) do
   print(v)
end

And if you wanted, lets say, 3 users per line you could do something like this:

local pad = "     "
local usersPerLine = 3
for i,v in ipairs(userTable) do
   write(v)
   if i % usersPerLine == 0 then
      print()
   else
      write(pad)
   end
end
faubiguy #3
Posted 22 October 2012 - 03:51 PM
textutils.tabulate(someTable) will print out the items that are in the indexed portion of a table. Use textutils.pagedTabulate(someTable) if the table contents go past the terminal height
Ditto8353 #4
Posted 22 October 2012 - 03:54 PM
…I should really pay more attention to the APIs that CC has…