ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 28 Jan 2012 11:57 AM |
Here's what I mean:
table1 = {1, 2, 3, 4, 5} table2 = {7,13,18,33,50}
-- when table1's value is 1, then table2's value should be 7. -- when table1's value is 2, then table2's value should be 13. -- I don't know how I should use the for statement like that. What should I do? |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 28 Jan 2012 12:00 PM |
local tableOne = {1, 2, 3, 4, 5} local tableTwo = {} for index, value in pairs(tableOne) do tableTwo[index] = value * 3 end
Is this what you want? |
|
|
| Report Abuse |
|
|
ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 28 Jan 2012 12:04 PM |
I'm not sure. But what I mean is:
table1 = {1,2,3,4,5} table2 = {10,12,31,96}
-- if table1 is 1, table2 is 10, if table1 is 2, table2 is 12, if table1 is 3, table2 is 31.
Please try to understand this. |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 28 Jan 2012 12:08 PM |
Can you please try and get some numbers to correspond with the ones in the first table so I can think of a formula?
Try this:
local tableOne = {1, 2, 3, 4, 5} local tableTwo = {10, 20, 30, 40, 50} for index, value in pairs(tableTwo) do if value == tableOne[index] * 10 then -- Code end end |
|
|
| Report Abuse |
|
|
ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 28 Jan 2012 12:12 PM |
Think of it like this:
enemies = {22, 27, 30, 36} level = { 1, 2, 3, 4 }
if the level is equal to 1, then there are 22 enemies. It's sorta like a wave.
But I want to keep it the way I'm doing it via tables |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 28 Jan 2012 12:14 PM |
| I can't really help you unless the numbers are compatible. For example, 22/22 = 1. 27/22 ~= 1. |
|
|
| Report Abuse |
|
|
ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 28 Jan 2012 12:16 PM |
| oh. Ok. Ty anyway, I guess I'll try to do the ways you showed me using a different method. |
|
|
| Report Abuse |
|
|
ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 28 Jan 2012 12:40 PM |
sigh. It didn't work. Here's my table names: devils = {} levels = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}
for i,v in pairs(levels) do for j,k in pairs(devils) do devils[k] = levels[v] * 13 -- supposed to make devils equal each level by 13 print(devils[j])
-- I can't get the 'devils' table to work with levels... |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 28 Jan 2012 12:52 PM |
local tableOne = {1, 2, 3, 4, 5} local tableTwo = {} for index, value in pairs(tableOne) do tableTwo[index] = value * 13 end for index, value in pairs(tableTwo) do print("Index - "..index.." : Value - "..value) end
Output: 13, 26, 39, 52, 65
|
|
|
| Report Abuse |
|
|