Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

how to get index number of an array using scriptcards?

Hi everyone, I have created two arrays. The first contains german words and the second contains the corresponding english field name of the character sheet. I'm trying to get the position of the german word to call the same position in the second array to get the fieldname. e.g. SKILLSG SKILLSE Akrobatik acrobatics Auftreten perform Beruf profession If I choose "Beruf" at SKILLSG then I need to get a 2 to use for retrieving "profession" out of SKILLSE. I have tried --~|getindex;SKILLSG;[&Fertigkeit] But it doesn't worked. I have read the WIKI-page over and over again, but my english is way to casual to get it right. My someone can help me out. Thanks in advance
So getindex only retrieves the current position in the array. If you want to search for the index of something, you'd want indexof. Like in this example there are 2 arrays like you have above. It loops through the German array and uses that value to get the index position and uses that index to get the corresponding English value in that array. !script {{ --#title|Translation Arrays --&EnglishSkillList|acrobatics,perform,profession --&GermanSkillList|Akrobatik,Auftreten,Beruf --~|array;fromstring;SKILLSG;,;[&GermanSkillList] --~|array;fromstring;SKILLSE;,;[&EnglishSkillList] --%G|foreach;SKILLSG --+German|[&G] --~Index|array;indexof;SKILLSG;[&G] --+English|[@SKILLSE([&Index])] --%| }}