crystantine
commited on
Commit
•
4c448e6
1
Parent(s):
f00c61a
Upload fcSuite.py
Browse files- fcSuite.py +99 -0
fcSuite.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import math
|
2 |
+
import sys
|
3 |
+
|
4 |
+
class fcFloatMatic:
|
5 |
+
def __init__(self):
|
6 |
+
pass
|
7 |
+
|
8 |
+
@classmethod
|
9 |
+
def INPUT_TYPES(cls):
|
10 |
+
return {
|
11 |
+
"required": {
|
12 |
+
"text": ("STRING", {"default": '', "multiline": True}),
|
13 |
+
"seed": ("INT", {"default": 0, "min": -1, "max": 0xffffffffffffffff, "step": 1}),
|
14 |
+
"increment_step": ("INT", {"default": 1, "min": 1, "max": 0xffffffffffffffff, "step": 1}),
|
15 |
+
},
|
16 |
+
"optional": {
|
17 |
+
"max_value": ("INT", {"default": 1, "min": 1, "max": 0xffffffffffffffff, "step": 1}),
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
RETURN_TYPES = ("FLOAT", "STRING") # Modified to return only FLOAT and STRING
|
22 |
+
FUNCTION = "process_text"
|
23 |
+
|
24 |
+
CATEGORY = "fc"
|
25 |
+
|
26 |
+
def process_text(self, text, seed=0, increment_step=1, max_value=None):
|
27 |
+
import io
|
28 |
+
new_text = []
|
29 |
+
for line in io.StringIO(text):
|
30 |
+
if not line.strip().startswith('#'):
|
31 |
+
line = line.replace("\n", '')
|
32 |
+
if line.strip():
|
33 |
+
float_line = list(map(float, line.split()))
|
34 |
+
new_text.extend(float_line)
|
35 |
+
|
36 |
+
output = math.floor(seed / increment_step) % (max_value or len(new_text))
|
37 |
+
if output < 0 or output >= len(new_text):
|
38 |
+
print(f"Invalid float index `{output}`")
|
39 |
+
return (0.0, "Invalid float index")
|
40 |
+
else:
|
41 |
+
selected_float = new_text[output]
|
42 |
+
seed += 1 # Increment the seed
|
43 |
+
return (selected_float, str(selected_float)) # Removed second integer output
|
44 |
+
|
45 |
+
class fcFloat:
|
46 |
+
def __init__(self) -> None:
|
47 |
+
pass
|
48 |
+
|
49 |
+
@classmethod
|
50 |
+
def INPUT_TYPES(cls):
|
51 |
+
return {
|
52 |
+
"required": {
|
53 |
+
"Value": ("FLOAT", {"default": 0.0, "min": -sys.float_info.max, "max": sys.float_info.max, "step": 0.1}),
|
54 |
+
},
|
55 |
+
}
|
56 |
+
|
57 |
+
RETURN_TYPES = ("FLOAT",)
|
58 |
+
CATEGORY = "fc"
|
59 |
+
FUNCTION = "get_value"
|
60 |
+
|
61 |
+
def get_value(self, Value):
|
62 |
+
return (Value,)
|
63 |
+
|
64 |
+
class fcInteger:
|
65 |
+
def __init__(self) -> None:
|
66 |
+
pass
|
67 |
+
|
68 |
+
@classmethod
|
69 |
+
def INPUT_TYPES(cls):
|
70 |
+
return {
|
71 |
+
"required": {
|
72 |
+
"Value": ("FLOAT", {
|
73 |
+
"default": 1.0,
|
74 |
+
"min": -sys.float_info.max,
|
75 |
+
"max": sys.float_info.max,
|
76 |
+
"step": 1.0
|
77 |
+
},
|
78 |
+
)
|
79 |
+
},
|
80 |
+
}
|
81 |
+
|
82 |
+
RETURN_TYPES = ("INT",)
|
83 |
+
CATEGORY = "fc"
|
84 |
+
FUNCTION = "get_value"
|
85 |
+
|
86 |
+
def get_value(self, Value):
|
87 |
+
return (int(Value),)
|
88 |
+
|
89 |
+
NODE_CLASS_MAPPINGS = {
|
90 |
+
"fcFloatMatic": fcFloatMatic,
|
91 |
+
"fcFloat": fcFloat,
|
92 |
+
"fcInteger": fcInteger,
|
93 |
+
}
|
94 |
+
|
95 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
96 |
+
"fcFloatMatic": "fcFloatMatic",
|
97 |
+
"fcFloatNode": "fcFloat",
|
98 |
+
"fcIntegerNode": "fcInteger",
|
99 |
+
}
|