embed script drop down

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

embed script drop down

Post by funksmaname »

would it be possible to scipt a drop down menu next to the tick box in the layer settings dialogue box to select an embed script from a predefined folder on your hard disk? (i.e. scripts/embedded/)

Whenever i go to the scripts tick box it defaults to another folder and i have to navigate to my script folder...

it's a workflow improvement and not that important i guess, but if it can be done quickly that would be awesome... maybe it can read a title bit of code form the script file to show as the name? so they have discriptive friendly names?

also, how about using more than one script per layer? is this possible in theory?

Thanks!
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

The drop down script selection would need to be a feature (feature request) added to AS and can't be done via scripting. It is a good idea though.

--------------

You can't have more than one script for a layer, however if you know a little bit of AS scripting it is possible to "combine" several scripts... not a simple procedure depending on the complexity of each script.

Another simpler option I have used in the past is to put several script "functions" inside a utility script and then call those functions from the layer script. You still need knowledge of scripting pull it off. Not the answer you are looking for I am sure. :)

I have pitched ideas for improvements to scripting for AS. I keep hoping. Scripting is not a huge priority for new features due to it's complexity but we get a few improvements in each version.

-vern
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

oh well... thanks for your response vern :)
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Re: embed script drop down

Post by Rudiger »

funksmaname wrote:would it be possible to scipt a drop down menu next to the tick box in the layer settings dialogue box to select an embed script from a predefined folder on your hard disk? (i.e. scripts/embedded/)

Whenever i go to the scripts tick box it defaults to another folder and i have to navigate to my script folder...

it's a workflow improvement and not that important i guess, but if it can be done quickly that would be awesome... maybe it can read a title bit of code form the script file to show as the name? so they have discriptive friendly names?

also, how about using more than one script per layer? is this possible in theory?

Thanks!
Hi funksmaname,

I threw together this little script that can automatically merge up to 3 embedded scripts into one, so that might do at least part of what you want, even though it's far from an ideal solution.

http://users.on.net/~alexical/Anime%20S ... s_v0.1.zip

The idea is you run this script, and specify up to 3 embedded scripts you want to merge. The file dialog comes up automatically for the first one, and then comes up each time you hit the add button. You then hit the OK button and choose the filename for the merged embedded script. I actually wanted it to be a lot fancier than it is, but, for the life of me, I couldn't work out how to make the layout dynamic by having another text control widget get added every time you press the Add button.

Unfortunately, if the script you specify for the merged file is already embedded, you will have to re-embed it to update it. If only setting the embedded script was scriptable, then you could add all of your requested features to this little dialog. Oh well, I guess this will have to do for now ;).
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

wow thanks! I will try to use this to merge MorphDials with MeshInstance - if it works it could really be very useful! :)

it works!!!
things to note for people; this is a MENU script, not an embedded script - so run it in the menu :) Also, when saving make sure to write .lua at the end of your file name ;)

So, here's how I got MorphDials and meshinstance to work together;
1) merge the apply_morphdials script with meshinstance
2) apply this script to 1 layer
3) apply normal meshinstance script to its duplicates
4) apply normal gen_morph script to the MorphDials layer

I'm going to experiment with this to see if I can use morphdials with Selgin's new improved headturn technique :) I see no reason why it won't work...
Thanks once again Rudiger!
Last edited by funksmaname on Fri Aug 27, 2010 10:17 pm, edited 1 time in total.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Rudiger,

This is a cool idea!

So is this basically "concatenating" the script files in one "bigger" script? My concern is variables and variable scope. For example what if one script uses the same variable names as another? Or are they separated during the merging process?

I will test it out to see how it works. Pretty darn cool.

Another cool aspect to this... you could actually have elements of scripts work "together". Attaching common functions first and then additional scripts could be added as needed that use the preloaded functions keeping the size smaller. I really like this.

-----------------

This is how I suggested to Mike that AS could work with layer scripts more effectively. Have multiple layer scripts assigned to layers by adding them to a list. Instead of a check box for just one script, a link "list" for each layer. Each layer script would run based on the order of placement.

-vern
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

i may have spoken too soon regarding the morphdials/meshinstance merge - it works as expected on frame 0 and using morphdials works as expected, but if you try to make point movement on any frame other than 0, it seems your tweaks are multiplied so slight movement in one direction results in very extreme movement in that direction...
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

heyvern wrote:Rudiger,

This is a cool idea!

So is this basically "concatenating" the script files in one "bigger" script? My concern is variables and variable scope. For example what if one script uses the same variable names as another? Or are they separated during the merging process?
Correct me if I'm wrong, but I don't think the values of local variables in layer scripts actually persist between frames, so name clashes shouldn't be an issue. For global variables, you would have to worry about name clashes anyway, even if the layer scripts were still separate. Having said that, this whole idea is still very experimental, so I'm hoping people will have the chance to try it out with actual layer scripts to see if any clashes do occur.

My initial approach was to rename the layer_script functions to <script_name>_layer_script and then add a layer_script function at the end that called these individual functions in sequence. This is much cleaner, but I'm still not clear on exactly what AS does with arbitrary functions defined in layer_scripts and whether this makes the layer_script slower.
funksmaname wrote: i may have spoken too soon regarding the morphdials/meshinstance merge - it works as expected on frame 0 and using morphdials works as expected, but if you try to make point movement on any frame other than 0, it seems your tweaks are multiplied so slight movement in one direction results in very extreme movement in that direction...
I didn't actually try merging these two scripts myself, so I can't guarantee that it will work. Did you definitely have the apply_morph_weights script first? When I get the chance, I will try it myself. By debugging the merged result, I should be able to work out what is going wrong.

EDIT: I just had a thought. You might have to place the duplicates outside the group that contains the MorphDials bone layer, otherwise it will try and apply the morph_weights to those layers too during any manual or automatic baking.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

unfortunately the dupes can't live outside the group as they are part of the masking setup... however the tweaks to the preferences fixed the point motion problem! for others benefit:

"Sounds like you may have the "Use existing main timeline keys as base" option enabled. I would disable this for the time being, and just have the "Preserve existing keys during real-time operation" option enabled instead."
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

funksmaname wrote:unfortunately the dupes can't live outside the group as they are part of the masking setup... however the tweaks to the preferences fixed the point motion problem! for others benefit:

"Sounds like you may have the "Use existing main timeline keys as base" option enabled. I would disable this for the time being, and just have the "Preserve existing keys during real-time operation" option enabled instead."
So, basically you are saying that the merge_embedded_scripts technique is working. That's great!

That's a good point about the dupes. I think I am going to have to make it so that you have to give the layers, that you want to apply the morph_weights to, special names as well.

By the way, I would advise everyone else to ignore the last part of funksmaname's post, as it only applies to the beta version of my MorphDials scripts that haven't been released yet ;).
User avatar
madrobot
Posts: 667
Joined: Mon Apr 07, 2008 3:07 pm

Post by madrobot »

... can dupes live outside the group where the initial meshinstanced layer lives? I had always assumed they could not - if they can, that would be AWESOME news.

(I use meshinstance for masking and shading, duping up through group folders would give me more control which is always welcome. Masking shading layers might sound unneccessarily convoluted, but I am on a crazy-tight schedule and establishing a workflow where I get in, draw it and keep moving - the faster the better.)
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

dunno dude, try it and report back! :)
User avatar
madrobot
Posts: 667
Joined: Mon Apr 07, 2008 3:07 pm

Post by madrobot »

Holy frozen poop on a stick, it looks like it works.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

the only thing is i sometimes get LUA errors that moan about the layer order - but it still works...
I wonder if there's a way to just completely supress all LUA errors - I still can't find another thing that makes about 50messages come up every time I undo while in Action mode...
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Undo can wreak havoc on layer scripts. Many of my scripts go kablooey with undo. Most of my layer scripts have a frame 0 "set up" and then do something different on other frames. Undo sort of confuses things. If the script that is having issues with undo has a different function for frame 0 this could be the cause.

In the past I have tried to "catch" the undo so I could "reload" the script but never could get it to work. I was trying to trap the key command for undo (there is no way to recognize the menu selection) and say something like "if undo then run this function". It didn't work.

-vern
Post Reply