|
| 07 Jul 2017 09:17 PM |
I've confused myself, lol
How would I store two variables in a key in a table: Minimum spawn level Max spawn level
So for example, if I have a enemy in a table, I want to define the min/max spawn level in the table too.
enemies = {enemy.Noob (min/max level stuff here), enemy.Noob2 (min/max level stuff here)}
I want to do something like that. It's probably rly simple but I'm tired and too lazy to be smart lol |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 07 Jul 2017 09:35 PM |
local enemies={ enemy.Noob={ Min=1, Max=2, }, enemy.Noob2={ Min=3, Max=4, } } |
|
|
| Report Abuse |
|
|
| |
|
RBXJared
|
  |
| Joined: 08 Sep 2011 |
| Total Posts: 469 |
|
|
| 07 Jul 2017 09:43 PM |
| You would basically create a table inside a table, Its called a Dictionary |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 09:46 PM |
'local enemies={ enemy.Noob={ Min=1, Max=2, }, enemy.Noob2={ Min=3, Max=4, } } '
This errors. ServerScriptService.WaveManager:4: '}' expected (to close '{' at line 3) near '='
|
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 09:49 PM |
It's because the keys were bad. This should compile:
local enemies = { Noob = { Min = 1, Max = 2, }, Noob2 = { Min = 3, Max = 4, } } |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 09:49 PM |
local enemies={ ["enemies.Noob"]={ Min=1, Min=2 }, ["enemies.Noob2"]={ Min=3, Min=4 } } |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 09:54 PM |
Question:
local waves = { wave1 = {Noob = 4}; wave2 = {Noob = 7}; wave3 = {Noob = 10}; }
I have a simple wave script. How would I define Noob as the first enemy? Typing ef.Noob will cause the table to error. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Jul 2017 10:19 PM |
| What do you mean, "define Noob as the first enemy?" It looks like you already have the first wave as 4 Noobs? |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 10:19 PM |
'What do you mean, "define Noob as the first enemy?" It looks like you already have the first wave as 4 Noobs?'
Yes, but should I have a "local Noob = ef.Noob" before the table to define them? |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 10:21 PM |
| Nvm, would "wave1 = {[ef.Noob] = 4}" work? |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2017 10:24 PM |
Just iterate through the waves like this to get them in the right order:
local waves = { {Noob = 4}, -- first wave {Noob = 7}, -- second {Noob = 10} -- third }
for i=1, #waves do for enemy, number in pairs(waves[i]) do print(enemy, number) end end |
|
|
| Report Abuse |
|
|
| |
|