Sign in or 

|
IEF015 |
Advanced Increment/Decrement Chip
Apr 17 2008, 4:02 PM EDT
Name: Advanced Increment/Decrement GateAuthor: IEF015 Edited Chip: Increment/Decrement Description: Increment/Decrement Gate with reset and more features. Example Uses: CODE: N@Adv. Inc/Dec Chip v1 I@A Inc Dec Reset ResetTo Max Min O@Value Value += Inc * A Value += Dec * -A Reset -> Value = ResetTo; Value > Max -> Value = Max; Value < Min -> Value = Min; ResetTo ? ResetTo : 0 Code explaination: Line 1: "Value" equals "A" added when "Inc" is on Line 2: "Value" equals "A" subtracted when "Dec" is on Line 3: When "Reset" is on, "Value" equals "ResetTo" Line 4: When "Value" is greater than "Max", then "Value" equals "Max" Line 5: When "Value" is less than "Min", then "Value" equals "Min" Line 6: When ResetTo has no input, then ResetTo will default to 0 0 out of 1 found this valuable. Do you?
Keyword tags:
Arithmetic
dec
decrement
inc
increment
|
|
MagnetoHydroDynamics |
1. RE: Advanced Increment/Decrement Chip
May 30 2008, 4:33 PM EDT
You might wanna add an A inputAnd do this: ~Inc & Inc == 1 -> Value += A ~Dec & Dec == 1 -> Value -= A Instead of Line 4 and 5 use this: Value = clamp(Min, Value, Max) You can even go as far as: Value = clamp(Min, (~Inc & Inc == 1 ? Value + A : (~Dec & Dec == 1 ? Value - A : Value)), Max) And simply fit it all into one line. Do you find this valuable? |
|
IEF015 |
2. RE: Advanced Increment/Decrement Chip
May 31 2008, 5:36 PM EDT
This is the one I use now:N@Adv. Inc/Dec Chip v1 I@AI AD Inc Dec Reset ResetTo Max Min O@Value Value += Inc * AI Value += Dec * -AD Reset -> Value = ResetTo; Value > Max -> Value = Max; Value < Min -> Value = Min; Do you find this valuable? |
|
MagnetoHydroDynamics |
3. RE: Advanced Increment/Decrement Chip
Jun 1 2008, 4:43 AM EDT
Ah i see, you have a boolean value as Inc and Dec...You might wanna use the clamp command instead of line 4 and 5: N@Adv. Inc/Dec Chip v1 I@A Inc Dec Reset ResetTo Max Min O@Value Value += Inc * A Value += Dec * -A Value = (Reset ? ResetTo : Value) Value = clamp(Min, Value, Max) Do you find this valuable? |