Variable assignment woes

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

Post Reply
User avatar
coatsiecoates
Posts: 15
Joined: Fri Dec 19, 2014 12:13 am

Variable assignment woes

Post by coatsiecoates » Thu Feb 22, 2018 2:24 pm

With a switch group, I can:

local layerName = moho.layer:Name()

then SetSelLayer to the parent and

moho.layer:SetValue((moho.frame), (layerName))

but have no idea how to manually specify layerName. It seems like it’d be as easy as

local layerName = “spam”, but I’m not getting results. Do I need a full path? Quotes?

If I had a switch group with layers named a, b, and c, how do I say layerName = c?
jezjones29
Posts: 335
Joined: Tue Jan 31, 2006 9:43 pm
Location: Wales, UK
Contact:

Re: Variable assignment woes

Post by jezjones29 » Thu Feb 22, 2018 5:01 pm

Code: Select all

 moho.layer:SetName('New Layer Name')
hayasidist
Posts: 2171
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Variable assignment woes

Post by hayasidist » Thu Feb 22, 2018 5:25 pm

are you trying to make c the active child with the parent selected??

You'll need to turn the generic layer into a switch type object:
http://www.mohoscripting.com/index.php? ... face&id=72

then do the set value
http://www.mohoscripting.com/index.php? ... yer&id=668

I think this should make c the active child with the parent selected

local switchLayer = moho:LayerAsSwitch(moho.layer)
switchLayer:SetValue (moho.frame, "c")
User avatar
coatsiecoates
Posts: 15
Joined: Fri Dec 19, 2014 12:13 am

Re: Variable assignment woes

Post by coatsiecoates » Thu Feb 22, 2018 11:49 pm

THANK YOU!!!

I was going bonkers! I've seen the word switchLayer so many times in the last 12 hours trying to figure it out, it lost all meaning and just started sounding like the name of some random metal band.

Turns out I had it right at one point during this effort, but was getting errors since I didn't have it indented and I abandoned the idea and moved on to alternative methods, but having it put in front of me like that made me reinvestigate.

God dang, I'm glad that's over.
User avatar
chucky
Posts: 3935
Joined: Sun Jan 28, 2007 4:24 am
Location: Van Diemen's Land
Contact:

Re: Variable assignment woes

Post by chucky » Sat Feb 24, 2018 11:13 am

coatsiecoates wrote:THANK YOU!!!

I was going bonkers! I've seen the word switchLayer so many times in the last 12 hours trying to figure it out, it lost all meaning and just started sounding like the name of some random metal band.
.
Nice one Coatsie, that would be a good name for a band, or a film/graphic novel.

"Some things, you just don't see coming"..... SWITCH LAYER....In theatres June.
Sequential offender.
my latest animations
Post Reply