Skip to content

Commit 4ee818c

Browse files
committed
allowed webgl_event() parent arg to be array of event objects, fixed incorrect limit handling
1 parent 3115c41 commit 4ee818c

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

js/webgl.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,13 @@ function webgl_entity_scale(args){
14901490

14911491
// Required args: parent, target
14921492
function webgl_event(args){
1493-
if(args.parent.event_limit !== false){
1493+
const array = core_type(args.parent) === 'array';
1494+
const event_todo = array
1495+
? args.parent
1496+
: args.parent.event_todo;
1497+
1498+
if(!array
1499+
&& args.parent.event_limit !== false){
14941500
if(args.parent.event_limit <= 0){
14951501
args.parent.event_range = false;
14961502
return;
@@ -1499,31 +1505,36 @@ function webgl_event(args){
14991505
args.parent.event_limit--;
15001506
}
15011507

1502-
for(const todo of args.parent.event_todo){
1508+
for(const todo of event_todo){
15031509
const modify = {...todo};
15041510
if(modify.limit !== void 0){
15051511
if(modify.limit <= 0){
15061512
continue;
15071513
}
15081514

1509-
modify.limit--;
1515+
todo.limit--;
15101516
}
15111517

1512-
for(const property in modify){
1513-
if(modify[property] === '_target'){
1514-
modify[property] = args.target.id;
1518+
if(!array){
1519+
for(const property in modify){
1520+
if(modify[property] === '_target'){
1521+
modify[property] = args.target.id;
1522+
1523+
}else if(modify[property] === '_self'){
1524+
modify[property] = args.parent.id;
15151525

1516-
}else if(modify[property] === '_self'){
1517-
modify[property] = args.parent.id;
1526+
}else{
1527+
const type = core_type(modify[property]);
15181528

1519-
}else if(core_type(modify[property]) === 'object'
1520-
|| core_type(modify[property]) === 'array'){
1521-
for(const id in modify[property]){
1522-
if(modify[property][id] === '_target'){
1523-
modify[property][id] = args.target.id;
1529+
if(type === 'object' || type === 'array'){
1530+
for(const id in modify[property]){
1531+
if(modify[property][id] === '_target'){
1532+
modify[property][id] = args.target.id;
15241533

1525-
}else if(modify[property][id] === '_self'){
1526-
modify[property][id] = args.parent.id;
1534+
}else if(modify[property][id] === '_self'){
1535+
modify[property][id] = args.parent.id;
1536+
}
1537+
}
15271538
}
15281539
}
15291540
}

0 commit comments

Comments
 (0)