From 54c2c1c5f76c39f102f1ffef06d0dd2de9175f4c Mon Sep 17 00:00:00 2001 From: tamat Date: Tue, 28 Feb 2023 13:28:57 +0100 Subject: [PATCH] fixes --- src/litegraph.js | 9 +++++++++ src/nodes/events.js | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/litegraph.js b/src/litegraph.js index 64b6f88c9..e6d23bd4d 100644 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -3192,6 +3192,15 @@ return; } + if(slot == null) + { + console.error("slot must be a number"); + return; + } + + if(slot.constructor !== Number) + console.warn("slot must be a number, use node.trigger('name') if you want to use a string"); + var output = this.outputs[slot]; if (!output) { return; diff --git a/src/nodes/events.js b/src/nodes/events.js index 4c8e51e20..5513c1419 100644 --- a/src/nodes/events.js +++ b/src/nodes/events.js @@ -437,7 +437,32 @@ LiteGraph.registerNodeType("events/semaphore", SemaphoreEvent); + function OnceEvent() { + this.addInput("in", LiteGraph.ACTION ); + this.addInput("reset", LiteGraph.ACTION ); + this.addOutput("out", LiteGraph.EVENT ); + this._once = false; + this.properties = {}; + var that = this; + this.addWidget("button","reset","",function(){ + that._once = false; + }); + } + OnceEvent.title = "Once"; + OnceEvent.desc = "Only passes an event once, then gets locked"; + + OnceEvent.prototype.onAction = function(action, param) { + if( action == "in" && !this._once ) + { + this._once = true; + this.triggerSlot( 0, param ); + } + else if( action == "reset" ) + this._once = false; + }; + + LiteGraph.registerNodeType("events/once", OnceEvent); function DataStore() { this.addInput("data", 0);