From 93384e6539e80c9ba7e20edee731c9c7bb7c557c Mon Sep 17 00:00:00 2001 From: xegim Date: Thu, 29 Jan 2026 11:33:43 +0100 Subject: [PATCH] Add float to string conversion --- __init__.py | 4 +++- nodes/converter.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 3cd315e..872b92c 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,5 @@ from .nodes.combiner import ETSplitTextNode, ETJoinTextNode, ETSwitchTextNode -from .nodes.converter import ETATOI, ETITOA +from .nodes.converter import ETATOI, ETITOA, ETFTOA from .nodes.formatter import ETTextFormatter2Node, ETTextFormatter5Node, ETTextFormatter10Node from .nodes.replacer import ETReplaceTextNode @@ -10,6 +10,7 @@ NODE_CLASS_MAPPINGS = { "ETATOI": ETATOI, "ETITOA": ETITOA, + "ETFTOA": ETFTOA, "ETTextFormatter2Node": ETTextFormatter2Node, "ETTextFormatter5Node": ETTextFormatter5Node, @@ -25,6 +26,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "ETATOI": "ATOI", "ETITOA": "ITOA", + "ETFTOA": "FTOA", "ETTextFormatter2Node": "Text Formatter (2 Arguments)", "ETTextFormatter5Node": "Text Formatter (5 Arguments)", diff --git a/nodes/converter.py b/nodes/converter.py index 9cfac9e..ea6f879 100644 --- a/nodes/converter.py +++ b/nodes/converter.py @@ -42,3 +42,26 @@ class ETITOA: def process(self, integer: int) -> tuple: return (str(integer),) + +class ETFTOA: + """ + A node that converts a float to a string. + """ + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "value": ("FLOAT", {"default": 0.0, "min": -2000000000, "max": 2000000000}), + "decimals": ("INT", {"default": 3, "min": 0, "max": 8}), + }, + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("text",) + + CATEGORY = "exectails/Strings" + FUNCTION = "process" + + def process(self, value: float, decimals: int) -> tuple: + return ("{:.{}f}".format(value,decimals),)