Page 2 of 2

Re: Script for switching multiple switches simultaneously

Posted: Sat Sep 02, 2017 5:24 pm
by hayasidist
ok
so...

Code: Select all

function Script(moho)

-- are we a switch layer on frame 0? N: abort

-- find a child .MASTER [?find first only?? check all and report error if >1??] [or assume first child is MASTER??] [or active child is MASTER?]

-- for each layer in .MASTER [i.e. every layer, irrespective of depth -- or will immediate children be OK?]
-- 	[or would it be better if just some (relevant) layers in MASTER are identified as "controlling" layers]
--	for each child of switch that is not .MASTER [aka slave child] [assume slave if not MASTER]
--		for each layer in slave child [again - all layers or just immediate child layers?]
--			if slave child layer name == .MASTER layer name
--				set slave child layer visibility to that of .MASTER
-- end if; end for; end for; end for
end 
((If that's the right idea then I'd be seriously tempted to make that a button script rather than a layer script since it's set-up only))

Re: Script for switching multiple switches simultaneously

Posted: Sat Sep 02, 2017 5:50 pm
by chucky
Ha ! that looks awesome!
I always prefer a button to embedding, so if you think it'll work then that would be so good.
So the recipe , could it be as simple as , toggle invisibility of all named the same as selected, inside the Master?

Re: Script for switching multiple switches simultaneously

Posted: Sun Sep 03, 2017 11:19 am
by hayasidist
chucky wrote:...So the recipe , could it be as simple as , toggle invisibility of all named the same as selected, inside the Master?
that suggests that you'd select a layer in master (e.g. thin lips) - set its visibility and run a script to set all others of the same name --- so you'd need to run this as many times as you have different layers - but yes could be.

Re: Script for switching multiple switches simultaneously

Posted: Sun Sep 03, 2017 3:16 pm
by Stan
Just an idea. You can have a tool script that will have some functionality running within the IsRelevant or IsEnabled method - that will run automatically every time something changes in the Layers panel. You can also have a checkbox (i.e. a boolean) in the tool's panel to turn that functionality on and off.

Re: Script for switching multiple switches simultaneously

Posted: Sun Sep 03, 2017 5:41 pm
by hayasidist
We've got a beta doing some behind the scenes iterations right now -- should be fit for public consumption in the next couple of days.

Just to whet the appetite: This is designed for use in set-up where the same structure has many options from which a one-time choice is made at set-up (e.g. same phoneme switch for many mouths - all the phonemes have all the mouth shapes - but only one is to be visible).

-- there's one "leader" switch child (per main option) and this holds things that have their visibility _manually_ toggled on or off
-- all the other switch children get their copy of the things made visible / invisible at the click of a tool button (or the execution of a menu item)
Stan wrote:Just an idea. You can have a tool script that will have some functionality running within the IsRelevant or IsEnabled method ...


Now that is an interesting use of those routines! Hmmm ... cogs whirr ...

Re: Script for switching multiple switches simultaneously

Posted: Sun Sep 03, 2017 7:49 pm
by synthsin75
hayasidist wrote:
Stan wrote:Just an idea. You can have a tool script that will have some functionality running within the IsRelevant or IsEnabled method ...


Now that is an interesting use of those routines! Hmmm ... cogs whirr ...
Yeah, I've used those for my auto-save script. These are called whenever you enter/leave frame zero, change a tool, change a layer, and maybe a few other things.

Re: Script for switching multiple switches simultaneously

Posted: Mon Sep 04, 2017 4:08 am
by chucky
Well, I can vouch for Paul's beta so for. It does an amazing job and has already saved me a lot of time and effort, Also my file is so much neater now. I can also make changes and additions without it getting bogged down with duplicates, references and all the malarkey.
Thanks hayasidist :D

Re: Script for switching multiple switches simultaneously

Posted: Mon Sep 04, 2017 1:07 pm
by hayasidist
here it is: https://www.mediafire.com/file/uxu0vb95 ... Switch.zip

The zip file contains:
- the script .lua file
- an icon .png file
- an example .moho file (created in moho 12.3)
- readme.txt

Installation - you can put the .lua as a menu item (e.g. the <custom folder>\scripts\menu\Visibility) or along with its icon in the tool folder <custom folder>\scripts\tool

Note that this is a "set-up" script not an animation script.

any bugs etc - please say!!

[edit] this is now V2.00

activate on any group type in any parent structure -- the visibility of that group's children is propagated to children of the same name in all groups in parent