[Closed] Multi-Conditional Arrays
I have a series of scenes containing characters with accessories. Object naming conventions in all of the scene files is the same, and most of the accessories for each character are the same, but there are a few accessories that differ from scene to scene.
One scene might have shirt, pants, shoes, and hat
Another scene might have shirt, pants, shoes, hat, and glasses
Another scene might have shirt, pants, shoes, glasses, and hat
I’ve learned how to created if/then conditional statements in maxscript, but I’m unsure how to created an array that contains all possible objects the script might run in to in such a way that if it doesn’t find one of them, the script will skip it and keep working.
What is the most efficient way to tackle something like this?
Do you mean a case statement?
case val of
(
1: doThis()
2: doThat()
3: TryThis()
4: TryThat()
default: ifAllElseFailsDoThis()
)
Off the top of my head, with case though the first fail or pass it matches it’ll pass that option and exit. For something like finding elements with a delimiter:
(
local types = #("sht", "pnt", "hat", "gla")
local filteredStr = #()
for o in objects do
(
filterStr = (filterString o.name "_")
if filterString.count > 1 and (findItem types filterStr[1]) != 0 do
(
case filterStr[1] of
(
"sht": doThisToTheShirt()
"pnt": doThisToPants()
"hat": doThisToHats()
"gla": doThisToGlasses()
)
)
)
)
I’d check as much as possible from the scene, superClass, etc…