Ok so I had a perfectly nice running set of scripts, and then I added a new one, and its all fallen apart. I have had to strip out nearly everything and I am still having issues. So currently I am getting an error with PowerCards and the following Aaron code: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode This was working fine, but when I added a new script it all went funny. Can I get any comments on whether this block of code relates to the above error. And any opinions on why PowerCards_Version = "3.2.18"; would do this (it isnt the first time either but the last time it suddenly went away). on('ready',function(){
"use strict";
var regex = {
stripSingleQuotes: /'([^']+(?='))'/g,
stripDoubleQuotes: /"([^"]+(?="))"/g
};
on('chat:message',function(msg){
var args,errors=[],who,cmd,characterid,createAttrs,character;
if('api' === msg.type && msg.content.match(/^!gsa\b/) ){
if(_.has(msg,'inlinerolls')){
msg.content = _.chain(msg.inlinerolls)
.reduce(function(m,v,k){
var ti=_.reduce(v.results.rolls,function(m2,v2){
if(_.has(v2,'table')){
m2.push(_.reduce(v2.results,function(m3,v3){
m3.push(v3.tableItem.name);
return m3;
},[]).join(', '));
}
return m2;
},[]).join(', ');
m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0;
return m;
},{})
.reduce(function(m,v,k){
return m.replace(k,v);
},msg.content)
.value();
}
args = msg.content
.replace(/<br\/>\n/g, ' ')
.replace(/(\{\{(.*?)\}\})/g," $2 ")
.split(/\s+--/);
cmd=args.shift().split(/\s+/);
characterid=_.last(cmd);
createAttrs=_.contains(cmd,'-c');
character=findObjs({
type: 'character',
id: characterid
})[0];
if(character){
let control = character.get('controlledby').split(/,/);
if(playerIsGM(msg.playerid) || _.contains(control,'all') || _.contains(control,msg.playerid)) {
_.chain(args)
.map(o=>{
let p=o.match(/("[^"]*"|'[^']'|.*?)[\|#]("[^"]*"|'[^']'|.*)/),
a,v;
if(p){
return {
attrName: p[1],
value: p[2].replace(regex.stripSingleQuotes,'$1').replace(regex.stripDoubleQuotes,'$1')
};
} else {
errors.push({
type: 'BadArgument',
value: o
});
}
})
.reject(_.isUndefined)
.map(o=>{
o.attr=findObjs({
type: 'attribute',
characterid: characterid,
name: o.attrName
})[0];
if(o.attr){
return o;
} else if(createAttrs){
createObj('attribute',{
characterid: characterid,
name: o.attrName,
current: o.value
});
} else {
errors.push({
type: 'MissingAttribute',
value: o.attrName
});
}
})
.reject(_.isUndefined)
.each(o=>{
o.attr.set({
current: o.value
});
});
} else {
errors.push({
type: 'NoCharacterAccess',
value: 'You are not allowed to access this character.'
});
}
} else {
errors.push({
type: 'MissingCharacter',
value: characterid
});
}
if(errors.length){
who=getObj('player',msg.playerid).get('_displayname');
sendChat('GSA',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Errors:</div>`+
_.chain(errors)
.map(e=>{
return `<div><b>${e.type}</b> ${e.value}</div>`;
})
.value()
.join('') +
`</div>`);
}
}
});
});