This commit is contained in:
KLL535
2025-01-21 23:52:00 +03:00
committed by GitHub
parent b1bcd41677
commit 1ced9f5283
10 changed files with 685 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
app.registerExtension({
name: "Simple Load Line From Text File",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "Simple Load Line From Text File") {
const origOnNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function() {
const r = origOnNodeCreated ? origOnNodeCreated.apply(this) : undefined;
let counter = 0;
function find_count(w) {
return w.name === "count"
}
const count = this.widgets.find(find_count);
count.type = "converted-widget"; // hidden
function do_counter() {
return counter++;
}
count.serializeValue = do_counter;
function reset_counter() {
counter = 0;
}
api.addEventListener("promptQueued", reset_counter); // reset
return r;
}
}
}
})