add randomint function

This commit is contained in:
pythongosssss
2023-08-16 21:02:55 +01:00
parent b5d7f4d526
commit 8da8d3a822
+14 -1
View File
@@ -1,5 +1,6 @@
import ast
import math
import random
import operator as op
operators = {
@@ -21,11 +22,15 @@ functions = {
},
"ceil": {
"args": (1, 1),
"call": lambda a : math.ceil(a)
"call": lambda a: math.ceil(a)
},
"floor": {
"args": (1, 1),
"call": lambda a: math.floor(a)
},
"randomint": {
"args": (2, 2),
"call": lambda a, b: random.randint(a, b)
}
}
@@ -51,6 +56,14 @@ class MathExpression:
FUNCTION = "evaluate"
CATEGORY = "utils"
@classmethod
def IS_CHANGED(s, expression, **kwargs):
if "random" in expression:
return float("nan")
return expression
def get_widget_value(self, extra_pnginfo, prompt, node_name, widget_name):
workflow = extra_pnginfo["workflow"]
node_id = None