Discord
Steam
/
Garry's Mod
/
Developers
/
Bodygroups
Login/Join
Event Log
Bodygroups
5 replies, posted
Search
In This Thread
If I wanted to add 2 different bodygroups with the same model to a table, how is this done?
Do you mean something like this? [lua]local tbl = { model = { bodygroup1 = { state1 = 1, state2 = 2, state3 = 3 }, bodygroup2 = { state1 = 1, state2 = 5 } } }[/lua]
you dont actually need the state in the sub body groups, but ye thats pretty much how you do it.
[QUOTE=RP-01;38229551]Do you mean something like this? [lua]local tbl = { model = { bodygroup1 = { state1 = 1, state2 = 2, state3 = 3 }, bodygroup2 = { state1 = 1, state2 = 5 } } }[/lua][/QUOTE] Like: [lua] models = { "models/humans/group17/female_01.mdl", "models/humans/group17/female_02.mdl", "models/humans/group17/female_03.mdl", "models/humans/group17/female_04.mdl", "models/humans/group17/female_06.mdl", "models/humans/group17/female_07.mdl", "models/humans/group17/female_01.mdl", "models/humans/group17/female_02.mdl", "models/humans/group17/female_03.mdl", "models/humans/group17/female_04.mdl", "models/humans/group17/female_06.mdl", "models/humans/group17/female_07.mdl", "models/humans/group17/male_01.mdl", "models/humans/group17/male_02.mdl", "models/humans/group17/male_03.mdl", "models/humans/group17/male_04.mdl", "models/humans/group17/male_05.mdl", "models/humans/group17/male_06.mdl", "models/humans/group17/male_07.mdl", "models/humans/group17/male_08.mdl", "models/humans/group17/male_09.mdl" }, [/lua] But with one of those models using a different bodygroup (I know none of them currently are)
Then do it like this: [lua] --first solution (more structured) local models = { { mdl = "models/humans/group17/female_01.mdl", bodygroup = 1 }, --[1] { mdl = "models/humans/group17/female_01.mdl", bodygroup = 2 }, --[2] { mdl = "models/humans/group17/female_02.mdl", bodygroup = 1 }, --[3] { mdl = "models/humans/group17/female_02.mdl", bodygroup = 2 } --[4] } --example on how to access the data and what's the output each print( "\n", models[1].mdl, models[1].bodygroup, "\n", models[2].mdl, models[2].bodygroup, "\n", models[3].mdl, models[3].bodygroup, "\n", models[4].mdl, models[4].bodygroup, "\n" ) --second solution (closer to what you've originally posted) local models = { { "models/humans/group17/female_01.mdl" --[[ [1] ]], bodygroup = 1 }, --[1] { "models/humans/group17/female_01.mdl" --[[ [1] ]], bodygroup = 2 }, --[2] { "models/humans/group17/female_02.mdl" --[[ [1] ]], bodygroup = 1 }, --[3] { "models/humans/group17/female_02.mdl" --[[ [1] ]], bodygroup = 2 } --[4] } --example on how to access the data and what's the output each print( "\n", models[1][1], models[1].bodygroup, "\n", models[2][1], models[2].bodygroup, "\n", models[3][1], models[3].bodygroup, "\n", models[4][1], models[4].bodygroup, "\n" ) [/lua]
Thanks!
Sorry, you need to
Log In
to post a reply to this thread.