Typocrite
|
  |
| Joined: 28 Aug 2013 |
| Total Posts: 6856 |
|
|
| 22 Jun 2014 01:56 PM |
For some reason it says it can't find "enemies" but yet I have defined it just a few lines above. What is wrong here?
Enemies = {"Troll"},{"Cursed Boar"},{"Orc"},{"Cave Troll"} --SELECT A RANDOM ENEMY function get_table(Enemies) random_item= Enemies[math.random(1,#Enemies)]
|
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 01:58 PM |
| Because you overrided the variable with the argument 'Enemies' in get_table's parameters. |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 02:00 PM |
Enemies = {["Troll"],["Cursed Boar"],["Orc"],["Cave Troll"]} function get_random(Table) return Table[math.random(1,#Table)] end print(get_random(Enemies)) |
|
|
| Report Abuse |
|
|
Typocrite
|
  |
| Joined: 28 Aug 2013 |
| Total Posts: 6856 |
|
|
| 22 Jun 2014 02:00 PM |
| Oh. Hmm. Removed it and it fixed. Thanks. |
|
|
| Report Abuse |
|
|