I am just wondering which statement is more efficient and recommended to use. I don't care about the code, I just want to know for future reference which way is better.
1:
1 | if game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 3 then |
2 | foodToChoose = tier_ 1 _tab |
3 | end |
4 |
5 | if game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 5 then |
6 | foodToChoose = tier_ 2 _tab |
7 | end |
2:
1 | if game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 3 then |
2 | foodToChoose = tier_ 1 _tab |
3 | elseif game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 5 then |
4 | foodToChoose = tier_ 2 _tab |
5 | end |
The 2nd one. But you would have to check the higher numbers first,
1 | if game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 5 then |
2 | foodToChoose = tier_ 2 _tab |
3 | elseif game.Players [ spawnNPC.Data.Owner.Value ] .Days.Value < 3 then |
4 | foodToChoose = tier_ 1 _tab |
5 | end |
So basically, if that value is higher than 5, no need to check for 3. If its not higher than 5, then check the next statement.