-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support expressions plugins/bundle #433
Conversation
Support extending the default JS functions. Added 'clamp' as an example.
Great news! I love it! cheers |
How to make a new functionAdd a target for the editor (autocomplete): src/core/Expressions/functions/myfunc.conf
Add the function: src/core/Expressions/functions/myfunc.js function myfunc(...) {
...
} Add the files to the resource file (manually or through Qt Creator): src/core/coreresources.qrc <qresource prefix="/expressions">
...
<file alias="myfunc.conf">Expressions/functions/myfunc.conf</file>
<file alias="myfunc.js">Expressions/functions/myfunc.js</file>
...
</qresource> And finally make sure it's loaded at startup: src/core/appsupport.cpp:1127
That's it, any user can now use that function. |
It's basic, but works for adding missing functions. I kept it simple so we can include this in 1.0 instead of waiting for 1.1. We will of course expand/improve on this in 1.1 |
OK, I get it, I'll try. Do you think it would be possible to include the "...can easily be modified to scan a user defined directory" option for v1.0? if not it would stay as something for just devs that are able to compile Friction by themselves, right? |
The initial idea was to add support for missing user requested functions like My only concern is that too many functions may add a performance penalty when the JS code is evaluated. |
Ok, latest commit adds support for external functions. Search paths:
|
Did you test it? Any idea? may I be doing anything wrong? Thanks |
You need a .conf file. |
btw, you can use sub-folders, Friction should go through all folders in search path. |
Added a new repo for misc expressions: https://github.com/friction2d/friction-expressions |
Great, I got it working! I'll play with some more expressions to have some for v1.0 (I'll PR them to the new repo) 😄 |
And I guess we will need to extend the "Expressions" Documentation section 😉 |
I can make a plugin manager ("Friction Store") for expressions and shaders for v1.1. Can probably reuse what I did for Natron: https://github.com/rodlie/NatronPluginManager |
Support extending the default selection of JS functions in Qt, currently only supports functions bundled with Friction ('clamp'), but can easily be modified to scan a user defined directory.
Added 'clamp' as an example:
@pgilfernandez