Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
on("change:repeating_skillsactionmod remove:repeating_skillsactionmod",function() {
var modifiers = {};
TAS.repeating("skillsactionmod")
.fields('skillsname','modifier','active') //< specifying the fields we care about
.reduce(function(m,r){
if(!(r.skillsaction_name in m.modifiers)){
m.modifiers[r.skillsaction_name] = 0;
}else{
if(r.active === "on"){
m.modifiers[r.skillsaction_name] += r.modifier;
}
}
return m;
},{modifiers: {}},function(m,r,a){
console.log("Nested TAS Call.");
console.log(m.modifiers);
TAS.repeating("skillsaction")
.fields('skillsaction_name','skillsaction_mod') //< specifying the fields we care about
.reduce(function(m,r){
//* HERE *
if(r.skillsaction_name in m.modifiers){
r.skillsaction_mod = m.modifiers[r.skillsaction_name];
console.log("Set "+r.skillsaction_name+" to "+m.modifiers[r.skillsaction_name]);
}else{
r.skillsaction_mod = 0;
console.log("Set "+r.skillsaction_name+" to "+0);
}
return m;
},{modifiers: {}})
.execute();
})
.execute();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment