How to get rid rid of {EXP::...}
-
I have an array full of SampleMaps from expansions... looks somewhat like this:
[ "{EXP::LIGHTER}UB_TH_ACM_KITCHEN GLITCH", "{EXP::LIGHTER}Lighter", "{EXP::LIGHTER}GIO_TEXTURES", "{EXP::LIGHTER}Ghosts in the Machines" ]
Now I want my viewport to show the names of the SampleMap only, without the {EXP::...LIGHTER} in front of it... How do I do that? Probably a little for loop... but what to put in there? Thanks for any advice on this!
-
@UrsBollhalder
var myString = "{EXP::LIGHTER}UB_TH_ACM_KITCHEN GLITCH"; myString = myString.replace("{EXP::LIGHTER}", "");
-
@ustk Thanks!!! Now. I've been fiddling around but can't figure out how to do that with the whole array?! I am trying something like this but obviously it doesn't work:
inline function loadSampleFromViewport(component, value) { var name = expSampleMaps[value].join("\n"); // this is an array of 4 names... and not a string... name = name.replace("{EXP::LIGHTER}", ""); ViewportsExp[1].set("items", name.join("\n")); } ViewportsExp[0].setControlCallback(loadSampleFromViewport);
-
@UrsBollhalder
I can't test right now, but try this:inline function loadSampleFromViewport(component, value) { for (n in name) n.replace("{EXP::LIGHTER}", ""); ViewportsExp[1].set("items", name.join("\n")); } ViewportsExp[0].setControlCallback(loadSampleFromViewport);
-
@ustk Awesome! Thanks so much. I’ll give it a go and can do some more digging if necessary!!
🥳
-
How are you populating the array initially?
-
@d-healey said in How to get rid rid of {EXP::...}:
How are you populating the array initially?
for(e in expHandler.getExpansionList()){ expansionNames.push(e.getProperties().Name); expSampleMaps.push(e.getSampleMapList()); }
Like this.
-
@UrsBollhalder Good :)
-
@d-healey said in How to get rid rid of {EXP::...}:
@UrsBollhalder Good :)
:grinning_face_with_sweat:
-
@d-healey @ustk Maybe not the most elegant, but it works... couldn't make the replace function working! So I split....
const var ViewportsExp = [Content.getComponent("vwpExp"), Content.getComponent("vwpSampleMaps")]; ViewportsExp[0].set("useList", true); ViewportsExp[1].set("useList", true); ViewportsExp[0].set("items", expansionNames.join("\n")); const var namesExp = []; inline function loadSampleFromViewport(component, value) { namesExp.clear(); var name = expSampleMaps[value]; for (n in name){ var sp = n.split("}"); namesExp.push(sp[1]); } ViewportsExp[1].set("items", namesExp.join("\n")); } ViewportsExp[0].setControlCallback(loadSampleFromViewport);
-
@UrsBollhalder Yeah replace won't work unless all of the sample maps are from the same expansion. You could also use substring().
-
@d-healey @UrsBollhalder I don't know very much expansions, but I thought there was a way to get the expansion name like:
n.replace("{EXP::" + getExpansionName() + "}", "");
-
@ustk That looks rather solid as well tbh!