Yes, but it's complicated. If you look at the Ammo script, there is a function in there for resolving the order of repeating attrs. If you don't care if they are in the same order as the sheet (or you want them in alphabetical order) it's much easier. const attrLookup = (character,name,caseSensitive) => {
let match=name.match(/^(repeating_.*)_\$(\d+)_.*$/);
if(match){
let index=match[2];
let attrMatcher=new RegExp(`^${name.replace(/_\$\d+_/,'_([-\\da-zA-Z]+)_')}$`,(caseSensitive?'i':''));
let createOrderKeys=[];
let attrs=_.chain(findObjs({type:'attribute', characterid:character.id}))
.map((a)=>{
return {attr:a,match:a.get('name').match(attrMatcher)};
})
.filter((o)=>o.match)
.each((o)=>createOrderKeys.push(o.match[1]))
.reduce((m,o)=>{ m[o.match[1]]=o.attr; return m;},{})
.value()
;
let sortOrderKeys = _.chain( ((findObjs({
type:'attribute',
characterid:character.id,
name: `_reporder_${match[1]}`
})[0]||{get:_.noop}).get('current') || '' ).split(/\s*,\s*/))
.intersection(createOrderKeys)
.union(createOrderKeys)
.value()
;
if(index<sortOrderKeys.length && _.has(attrs,sortOrderKeys[index])){
return attrs[sortOrderKeys[index]];
}
return;
}
return findObjs({ type:'attribute', characterid:character.id, name: name}, {caseInsensitive: !caseSensitive})[0];
};
You can use that with something like: let character = getObj('character',someCharID);
let name1 = attrLookup(character,'repeating_ammo_$1_ammoname');