Thread: Tables
View Single Post
07-11-10, 07:25 PM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
lua Code:
  1. local registers = {
  2.     {value1 = 1, value2 = 3},
  3.     {value1 = 1, value2 = 100},
  4.     {value1 = 1, value2 = 365}
  5. }
  6.  
  7. local total_value1, total_value2 = 0, 0
  8. for regnum, register in pairs(registers) do
  9.     total_value1 = total_value1 + register.value1
  10.     total_value2 = total_value2 + register.value2
  11. end
  12.  
  13. print("The total of value1 is", total_value1, "The total of value2 is", total_value2)
Would output "The total of value1 is 3 The total of value2 is 468"

As a quick example.

Last edited by Slakah : 07-11-10 at 07:31 PM.
  Reply With Quote