Bean666 Posted February 1, 2021 Posted February 1, 2021 (edited) Hi i just wanna know if i did it correctly, i created teams from a table, like this, it works fine, it creates the teams in the table, but i just wanna know if there's a better way / optimized of doing it or is this fine? local teams = { { "Team1", 0, 180, 0 }, { "Team2", 180, 50, 50 } } for k,v in ipairs( teams ) do teams = createTeam ( v[1], v[2], v[3], v[4]) end Edited February 1, 2021 by Shaman123
Moderators Citizen Posted February 1, 2021 Moderators Posted February 1, 2021 You have the most optimized way of creating the teams. But this code teams = createTeam is wrong, as you are overriding the teams variable as you are iterating over that list. The 1st one gets created, the second should fail because that teams variable just changed for the team entity you created in the 1st iteration of the loop. You can also write it like this (by using unpack): for k, v in ipairs( teams ) do createTeam( unpack(v) ) -- unpack can be used here because it is in the same order end but it's less optimized (if this is not a time critical code, then it will just save you time writing the code, but not by much either :p) 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now