|
1073 | 1073 | for (var i = 0; i < num; i++) { |
1074 | 1074 | for (var j = 0; j < limit; ++j) { |
1075 | 1075 | var node = nodes[j]; |
| 1076 | + node.executePendingActions(); |
1076 | 1077 | if (node.mode == LiteGraph.ALWAYS && node.onExecute) { |
1077 | 1078 | //wrap node.onExecute(); |
1078 | 1079 | node.doExecute(); |
|
1094 | 1095 | for (var i = 0; i < num; i++) { |
1095 | 1096 | for (var j = 0; j < limit; ++j) { |
1096 | 1097 | var node = nodes[j]; |
| 1098 | + node.executePendingActions(); |
1097 | 1099 | if (node.mode == LiteGraph.ALWAYS && node.onExecute) { |
1098 | 1100 | node.onExecute(); |
1099 | 1101 | } |
|
3190 | 3192 | this.mode = modeTo; |
3191 | 3193 | return true; |
3192 | 3194 | }; |
| 3195 | + |
| 3196 | + /** |
| 3197 | + * Triggers the execution of actions that were deferred when the action was triggered |
| 3198 | + * @method executePendingActions |
| 3199 | + */ |
| 3200 | + LGraphNode.prototype.executePendingActions = function() { |
| 3201 | + if(!this._waiting_actions || !this._waiting_actions.length) |
| 3202 | + return; |
| 3203 | + for(var i = 0; i < this._waiting_actions.length;++i) |
| 3204 | + { |
| 3205 | + var p = this._waiting_actions[i]; |
| 3206 | + this.onAction(p[0],p[1],p[2],p[3],p[4]); |
| 3207 | + } |
| 3208 | + this._waiting_actions.length = 0; |
| 3209 | + } |
| 3210 | + |
3193 | 3211 |
|
3194 | 3212 | /** |
3195 | 3213 | * Triggers the node code execution, place a boolean/counter to mark the node as being executed |
3196 | | - * @method execute |
| 3214 | + * @method doExecute |
3197 | 3215 | * @param {*} param |
3198 | 3216 | * @param {*} options |
3199 | 3217 | */ |
|
3204 | 3222 | // enable this to give the event an ID |
3205 | 3223 | if (!options.action_call) options.action_call = this.id+"_exec_"+Math.floor(Math.random()*9999); |
3206 | 3224 |
|
3207 | | - if(this._waiting_actions && this._waiting_actions.length) |
3208 | | - for(var i = 0; i < this._waiting_actions.length;++i) |
3209 | | - { |
3210 | | - var p = this._waiting_actions[i]; |
3211 | | - this.onAction(p[0],p[1],p[2],p[3],p[4]); |
3212 | | - } |
3213 | | - |
3214 | 3225 | this.graph.nodes_executing[this.id] = true; //.push(this.id); |
3215 | 3226 |
|
3216 | 3227 | this.onExecute(param, options); |
|
3225 | 3236 | } |
3226 | 3237 | } |
3227 | 3238 | else { |
3228 | | - if(this._waiting_actions && this._waiting_actions.length) |
3229 | | - for(var i = 0; i < this._waiting_actions.length;++i) |
3230 | | - { |
3231 | | - var p = this._waiting_actions[i]; |
3232 | | - this.onAction(p[0],p[1],p[2],p[3],p[4]); |
3233 | | - } |
3234 | 3239 | } |
3235 | 3240 | this.execute_triggered = 2; // the nFrames it will be used (-- each step), means "how old" is the event |
3236 | 3241 | if(this.onAfterExecuteNode) this.onAfterExecuteNode(param, options); // callback |
|
0 commit comments