Skip to content

Commit

Permalink
added some convenience API methods for script variables
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-thomm committed Oct 27, 2020
1 parent a234169 commit fc5951c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
14 changes: 14 additions & 0 deletions Ryven/custom_src/NodeInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,23 @@ def get_default_stylesheet():
"""Handy method for subclasses to access the application window's stylesheet for UI content."""
return Design.ryven_stylesheet

# VARIABLES

def get_vars_handler(self):
return self.flow.parent_script.variables_handler

def get_var_val(self, name):
return self.get_vars_handler().get_var_val(name)

def set_var_val(self, name, val):
return self.get_vars_handler().set_var(name, val)

def register_var_receiver(self, name, method):
self.get_vars_handler().register_receiver(self, name, method)

def unregister_var_receiver(self, name):
self.get_vars_handler().unregister_receiver(self, name)

# --------------------------------------------------------------------------------------
# UI STUFF ----------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Ryven/custom_src/builtin_nodes/GetVar_NodeInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def update_event(self, input_called=-1):
self.set_output_val(0, None)

else: # ->> value changed!
self.set_output_val(0, self.get_vars_handler().get_var_val(self.var_name))
self.set_output_val(0, self.get_var_val(self.var_name))

def var_val_changed(self, name, val):
self.update()
Expand Down
8 changes: 4 additions & 4 deletions Ryven/custom_src/builtin_nodes/SetVar_NodeInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def __init__(self, params):
def update_event(self, input_called=-1):
if self.active and input_called == 0:
self.var_name = self.input(1)
vars_handler = self.get_vars_handler()
if vars_handler.set_var(self.input(1), self.input(2)):
# vars_handler = self.get_vars_handler()
if self.set_var_val(self.input(1), self.input(2)):
self.set_output_val(1, self.input(2))
self.exec_output(0)
elif not self.active:
self.var_name = self.input(0)
if self.get_vars_handler().set_var(self.input(0), self.input(1)):
self.set_output_val(0, self.get_vars_handler().get_var_val(self.var_name))
if self.set_var_val(self.input(0), self.input(1)):
self.set_output_val(0, self.get_var_val(self.var_name))


def action_make_passive(self):
Expand Down
2 changes: 1 addition & 1 deletion saves/mixed examples.rpo

Large diffs are not rendered by default.

0 comments on commit fc5951c

Please sign in to comment.