aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime
diff options
context:
space:
mode:
authorJakob Stendahl <jakobste@uio.no>2021-10-21 14:12:12 +0200
committerJakob Stendahl <jakobste@uio.no>2021-10-21 14:12:12 +0200
commitf243dc8d7527cde3d5b5a4f6e659cf7604f5ae2a (patch)
tree143b71f2bb6b84370505473d4624d52f1e264bb0 /NeoRuntime
parenta69d9dbc80dfaa0fc3eef3b5ac48e1c2a25fa08b (diff)
downloadLuxcena-Neo-f243dc8d7527cde3d5b5a4f6e659cf7604f5ae2a.tar.gz
Luxcena-Neo-f243dc8d7527cde3d5b5a4f6e659cf7604f5ae2a.zip
:sparkles: Make all variable-types changeable from both home and editor
Diffstat (limited to 'NeoRuntime')
-rw-r--r--NeoRuntime/Runtime/luxcena_neo/__init__.py2
-rw-r--r--NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py20
2 files changed, 9 insertions, 13 deletions
diff --git a/NeoRuntime/Runtime/luxcena_neo/__init__.py b/NeoRuntime/Runtime/luxcena_neo/__init__.py
index 606f365..91fdfba 100644
--- a/NeoRuntime/Runtime/luxcena_neo/__init__.py
+++ b/NeoRuntime/Runtime/luxcena_neo/__init__.py
@@ -1,2 +1,2 @@
-from .neo_behaviour import NeoBehaviour, VariableType, ColorVariable, FloatVariable, IntegerVariable, BooleanVariable
+from .neo_behaviour import NeoBehaviour, VariableType, ColorVariable, FloatVariable, IntegerVariable, BooleanVariable, Trigger
import luxcena_neo.color_utils as utils
diff --git a/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py b/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py
index 2eef444..d4ee9bd 100644
--- a/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py
+++ b/NeoRuntime/Runtime/luxcena_neo/neo_behaviour.py
@@ -210,7 +210,7 @@ class IntegerVariable(Variable):
def __init__(self, name: str, default: int = 0, min_val: int = 0, max_val: int = 255, **kwargs):
self.__min = min_val
self.__max = max_val
- super().__init__(name, default, VariableType.INT)
+ super().__init__(name, default, VariableType.INT, **kwargs)
@Variable.value.setter
def value(self, value):
@@ -229,10 +229,11 @@ class IntegerVariable(Variable):
class FloatVariable(Variable):
- def __init__(self, name: str, default: float = 0.0, min_val: float = 0.0, max_val: float = 255.0, **kwargs):
+ def __init__(self, name: str, default: float = 0.0, min_val: float = 0.0, max_val: float = 255.0, step: float = 0.5, **kwargs):
self.__min = min_val
self.__max = max_val
- super().__init__(name, default, VariableType.FLOAT)
+ self.__step = step
+ super().__init__(name, default, VariableType.FLOAT, **kwargs)
@Variable.value.setter
def value(self, value):
@@ -249,19 +250,19 @@ class FloatVariable(Variable):
return round(self.value, 2)
def to_dict(self):
- return {"name": self.name, "value": self.value, "type": self.var_type, "min": self.__min, "max": self.__max}
+ return {"name": self.name, "value": self.value, "type": self.var_type, "min": self.__min, "max": self.__max, "step": self.__step}
class BooleanVariable(Variable):
def __init__(self, name: str, default: bool, **kwargs):
- super().__init__(name, default, VariableType.BOOL)
+ super().__init__(name, default, VariableType.BOOL, **kwargs)
@Variable.value.setter
def value(self, value):
try:
- value = bool(value)
+ value = value.lower() == "true"
super(BooleanVariable, type(self)).value.fset(self, value)
except:
print("Attempted to set {} to \"{}\", which is not a valid bool...".format(self.name, value))
@@ -273,9 +274,4 @@ class Trigger(Variable):
@Variable.value.setter
def value(self, value):
- try:
- value = bool(value)
- if value: value = False
- super(BooleanVariable, type(self)).value.fset(self, value)
- except:
- print("Attempted to set {} to \"{}\", which is not a valid bool...".format(self.name, value))
+ super(Trigger, type(self)).value.fset(self, False)