SwitchSlave

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

SwitchSlave

Post by 7feet » Sat Oct 15, 2005 5:56 pm

Okay, I'm rolling today. There was adiscussion in one of the other sections about controlling one switch layer with another. Sounded like a fine idea, so...

SwitchSlave

Tiny litttle embedded script, that makes one switch layer mimic the switch changes of another.

--Both Switch layers need to be at the same level, i.e. they are both root layers, or both within the same group.

--The sub-layers in both switch layers must have the same names. This is important.

--The Switch layer you want to control must have ".sslv" at the end of the name (make sure it's in lowercase). Thats how the script finds the layer you want to control

--Assign the SwitchSlave script to the master layer (the "Embedded script file" checkbox in the Layer Properties). It'll find the layer you want to be controlled and do it's thing.

--Any old keyframes in the slave layer will be lost. It copy the switches on the master layer exactly, in realtime. Pretty neat, huh?

Have fun.
ulrik
Posts: 1075
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik » Sat Oct 15, 2005 10:13 pm

This little script works like a charm!!!
I even tried and made 5 copies of it, added 1, 2 etc. at the end of the "SwitchSlave"name, opened the scripts in textwrangler and changed the .sslv to ssl1, ssl2 and so on and it made me have several different switch information to slave several different switch layers...nice work 7feet!, and thanks a lot :D
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet » Sat Oct 15, 2005 10:44 pm

Glad you dig it. I was actually going to point out that you could change that, but I spaced. For the rest of y'all, open up the script in any old text editor and look for this line -

Code: Select all

if (string.sub(name, -5) == ".sslv") then
It's in there twice, but it's not hard to find, it's really a pretty tiny script. You can change the letters of the extension to any old thing you want. If you wanted to change the extension, say, to "_HeadSlave", the line would be -

Code: Select all

if (string.sub(name, -10) == "_HeadSlave") then
The change to "-10" is because the extension has 10 characters in it. Then save the file and everything is happy.

Now, that might also be a temporary solution. One thing I thought to do is to put the master and slave layer names into a separate file. As an example, you set up something like this:

Code: Select all

master head
slave hair front
slave hair back
slave hair shadow
master bald head
slave cueball reflection
Then you get to both use just one script, and have that script control multiple slave layers. We'll see.
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Post by rylleman » Tue Oct 18, 2005 9:15 am

Great script Brian!, thank you!

Now, would it be possible to have the script work in sub-levels of the rig hierarchy?
as:
head (master group)
_eyes control (switch layer, the layer to attach the script to)
_HEAD (switch layer)
__*head_1 (bone layer)
____-eyes_head_1 (switch layer)
__*head_2 (bone layer)
____-eyes_head_2 (switch layer)
__*head_2 (bone layer)
____-eyes_head_2 (switch layer)
... (every switch should of course be named properly)

In this example, to have the control script be the master over the eyes swithes inside the different head bone groups?
User avatar
Ramón López
Posts: 1802
Joined: Sun Aug 08, 2004 1:41 pm
Location: Elda! Again...
Contact:

Post by Ramón López » Tue Oct 18, 2005 7:27 pm

:) It seems like another GREAT script by 7feet!!! And it's Embedded!!! YOo-HoOOo! THANKS! I think I could love it if I'd decide use again Switch Layers in my proyects, althought now that I can do my LipSync works with Actions 8) I think it's not probable for now... (Jijiji :lol: , I feel SO free now... Ahhh... :roll: ) Anyway, thank you very much :D , I'm very happy to see how someone produce and take benefits of this magic feature called Embedded Scripts! :D
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Post by rylleman » Wed Oct 19, 2005 9:29 am

I've come up with a great usage of this script that I have to share. I actually had a similar thing on my list of "scripts that I'm going to write when I get the time and knowledge", but I found out that I can do pretty much the same thing with this script.
The usage I have in mind is to keep track of your switches which, when having a lot of them, can be quite confusing at times.
Create a slave switch-layer in which you create note layers with the same names and note text as the switch you are going to keep track of and assign this script to the master switch.
Now you got a notelayer in view that tells you exactly which switch you got at any given frame!
This has been a great help for me the last couple of days.
User avatar
jahnocli
Posts: 3371
Joined: Fri Oct 29, 2004 2:13 pm
Location: UK

Post by jahnocli » Wed Oct 19, 2005 9:52 am

I'm intrigued, but I don't quite get it. Could you post a screen shot of the layers palette to show what you mean?
You can't have everything. Where would you put it?
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet » Wed Oct 19, 2005 10:55 am

rylleman - Well that's not a use I had thought of. Good one. I'll look into your other extension request as soon as I can.
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 5:22 pm
Location: sweden
Contact:

Post by rylleman » Wed Oct 19, 2005 8:37 pm

A little bug report for you;
Sometimes I get an error message in the lua console, unable to index local "layer". At line 9.
Nothing happens and everything works as normal after I close the console but it might be something to look into.
User avatar
xian
Posts: 19
Joined: Wed Sep 14, 2005 7:50 pm
Location: Cleveland, OH

Post by xian » Thu Oct 20, 2005 5:22 pm

Thank you 7.

This is a great addition to the MOHO toolset.

I appreciate that you saw enough value in the concept to act.

Good Day, Sir.
Can I get a blue spot?
User avatar
Ramón López
Posts: 1802
Joined: Sun Aug 08, 2004 1:41 pm
Location: Elda! Again...
Contact:

Post by Ramón López » Tue Feb 07, 2006 8:23 pm

...Ey! 7feet, How are you? :) I'm very interested now in this script cause maybe with some modifications could resolve a lot of problems in my actual line of work... The fist thing that I've tried to change is can turn the script "inactive" when you are inside an Action, you know, to avoid "Action Destruction" (you will remember a similar problem in the first steps of the Bone Control/Master Scripts...) Well, I think there must be a way to make it possible, but I've been basically adding all possible variations of this lines of code with no more than error messages or no changes...

Code: Select all

    if (moho.layer:CurrentAction() ~= "") then 
        return false 
    return true 
end
Do you think this could be possible? A simple instruction to make script be stopped if (moho.layer:CurrentAction() ~= "") is active? I think yes cause is the way all other scripts work and it seems logical to me, but well, this is not a "normal" script and really (in general) I have not idea :roll: ...Well, anyway THANK YOU! Starting for have wrote this useful script and for/if any help, CIAO!


EDIT: ...DONE! :D (Well, this little part at least...)
User avatar
slowtiger
Posts: 5493
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Not downloadable

Post by slowtiger » Sun Mar 12, 2006 6:27 pm

I tried to download this script, but the host is not connected. Is this temporarily? Is there another place where I could get this? Would someone be so nice and mail it to me? TIA, slowtiger
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet » Sun Mar 12, 2006 8:23 pm

slowtiger - the place my scripts are is kind of a test site for a web file server, so sometimes it disappears when they do upgrades. Ususally back up shortly, if not I'll track a copy down and shoot it to you.
User avatar
jackthegiantkiller
Posts: 9
Joined: Mon Mar 13, 2006 7:58 pm

Site still down...

Post by jackthegiantkiller » Mon Mar 13, 2006 8:01 pm

Anywhere else this can be downloaded? Site is still down.
User avatar
jackthegiantkiller
Posts: 9
Joined: Mon Mar 13, 2006 7:58 pm

Got it!

Post by jackthegiantkiller » Tue Mar 14, 2006 12:28 am

Got it! Site came back up!
Post Reply