mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 06:22:13 -03:00
0.22
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import re
|
||||
import random
|
||||
import time
|
||||
import logging
|
||||
class WriteTextInConsole:
|
||||
@classmethod
|
||||
@@ -16,6 +19,25 @@ class WriteTextInConsole:
|
||||
OUTPUT_IS_LIST = (False,)
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def write_text_in_console(self, text):
|
||||
def write_text_in_console(self, text, seed=None, control_after_update=None):
|
||||
logging.info(f"Text: {text}")
|
||||
return {"ui": {"text": text}, "result": (text,)}
|
||||
# If seed is not provided, generate a new one
|
||||
if seed is None:
|
||||
seed = int(time.time() * 1000)
|
||||
|
||||
# Use the seed to initialize the random number generator
|
||||
random.seed(seed)
|
||||
|
||||
def replace_random(match):
|
||||
options = match.group(1).split('|')
|
||||
return random.choice(options)
|
||||
|
||||
pattern = r'\{([^}]+)\}'
|
||||
result = re.sub(pattern, replace_random, text)
|
||||
|
||||
return (result,)
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(s, text, seed=None, control_after_update=None):
|
||||
# This method is called to determine if the node needs to be re-executed
|
||||
return float("nan") # Always re-execute to ensure consistency
|
||||
Reference in New Issue
Block a user