Files
fluxscape/packages/noodl-runtime/src/nodes/std-library/booleantostring.js
Michael Cartner b9c60b07dc Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com>
Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com>
Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com>
Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com>
Co-Authored-By: Johan  <4934465+joolsus@users.noreply.github.com>
Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com>
Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
2024-01-26 11:52:55 +01:00

72 lines
1.8 KiB
JavaScript

'use strict';
const BooleanToStringNode = {
name: 'Boolean To String',
docs: 'https://docs.noodl.net/nodes/utilities/boolean-to-string',
category: 'Utilities',
initialize: function () {
this._internal.inputs = [];
this._internal.currentSelectedIndex = 0;
this._internal.indexChanged = false;
this._internal.trueString = '';
this._internal.falseString = '';
},
inputs: {
trueString: {
displayName: 'String for true',
type: 'string',
set: function (value) {
if (this._internal.trueString === value) return;
this._internal.trueString = value;
if (this._internal.currentInput) {
this.flagOutputDirty('currentValue');
}
}
},
falseString: {
displayName: 'String for false',
type: 'string',
set: function (value) {
if (this._internal.falseString === value) return;
this._internal.falseString = value;
if (!this._internal.currentInput) {
this.flagOutputDirty('currentValue');
}
}
},
input: {
type: { name: 'boolean' },
displayName: 'Selector',
set: function (value) {
if (this._internal.currentInput === value) return;
this._internal.currentInput = value;
this.flagOutputDirty('currentValue');
this.sendSignalOnOutput('inputChanged');
}
}
},
outputs: {
currentValue: {
type: 'string',
displayName: 'Current Value',
group: 'Value',
getter: function () {
return this._internal.currentInput ? this._internal.trueString : this._internal.falseString;
}
},
inputChanged: {
type: 'signal',
displayName: 'Selector Changed',
group: 'Signals'
}
}
};
module.exports = {
node: BooleanToStringNode
};