Hi,
Is there a way to perform an action if a value is changed?
The logic would be something like this:
If new value != with the existing value:
do something:
Here is the existing code (inside of a Python node in an Expresso)
import c4d
#Welcome to the world of Python
def main():
store_value = 0 # The value ranges from 0 or 1
if Input1 != store_value:
print "Something changed"
store_value = Input1
else:
print "Nothing changed"
The problem is at next draw/redraw/refresh the store_value stays at zero even though the Input is already at 1. This means the store_value = Input1
is not working.
You can check the illustration file here:
https://www.dropbox.com/s/y5ujqcp6ziecos3/c4d123_do_something_if_something_is_chang.c4d?dl=0
Upon opening the file, you'll see in the console printing "Nothing Changed" repeatedly. Now if you change the user data. It prints "Something Changed" but then it continuously prints "Something is changed".
The result should be something like
Nothing Changed
# Changes user data
Something changed
# Back to
Nothing Changed
Nothing Changed
Is there a way around this? Thank you for looking at the problem