### Author Topic: How to re-use the same math on multiple nodes? Can I create my own Function?  (Read 626 times)

#### justaviking

I feel like I'm overlooking something obvious.

SCENARIO:
- Suppose I have several nodes, all doing very similar things, based on the \$TIME variable
- They all include the same complex math function, but with one minor difference at the end
- - - Node 1:   \$TIME * (complex math function) + 0.3
- - - Node 2:   \$TIME * (complex math function) + 1.1
- - - Node 2:   \$TIME * (complex math function) + 7.8
- The "complex math function" is the same for all the nodes

QUESTION:
- How can I create the "complex math function" one time, and then use it in each of the other functions?
- Can I define my own function?

WHY?
- Especially during the development phase, I made adjustments to that math function, which means I had to edit all three nodes over and over and over again.  (I used copy/paste a lot.)  It sure would have been nice to make a single edit in one place.
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html

#### luc.chamerlat.allegorithmic

Hi justavinking !

Yes you can do it by creating a new function that will be called by your parameters, I did a gif to show you :

I didn't use the \$time value for this example, but it will work the same way.

Hope it helps.
Q.A Analyst

#### justaviking

Thank you for the reply, Luc.

I might still be missing Step #1, but I will give it a try again this evening.

I know how to make a "function" in the context of a node, such as what you did for the "Disorder" value.  But I could not find where to make the function that lives outside of an existing node.  That's the magical step I'm missing.

Where did you go to START the CREATION of Function Node named "My Math"?  It's probably something obvious I simply overlooked, and will embarrassed when I find it.
Last Edit: May 16, 2018, 03:11:15 pm
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html

#### luc.chamerlat.allegorithmic

You just need to right click on your package and select New > Substance Function

You're right, maybe we should make it more visible !
Q.A Analyst

#### justaviking

You just need to right click on your package and select New > Substance Function

That is the missing key!

Thanks again.  Looking forward to doing that when I get home.