42 lines
988 B
Python
42 lines
988 B
Python
class GetLine:
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"text": ("STRING", {
|
|
"multiline": True,
|
|
"default": "A cat\nA dog\nA bird\n"
|
|
}),
|
|
"index": ("INT", {
|
|
"default": 0,
|
|
"min": 0,
|
|
"step": 1,
|
|
"display": "number",
|
|
"control_after_generate": "increment"
|
|
}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("STRING",)
|
|
RETURN_NAMES = ("line",)
|
|
FUNCTION = "get_line"
|
|
CATEGORY = "SBCODE"
|
|
|
|
def get_line(self, text, index):
|
|
lines = text.splitlines()
|
|
|
|
if not lines:
|
|
return ("",)
|
|
|
|
safe_index = index % len(lines)
|
|
return (lines[safe_index],)
|
|
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
"Get Line": GetLine
|
|
}
|
|
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"Get Line": "Get Line"
|
|
}
|