Variable assignment woes

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

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Variable assignment woes

Post by coatsiecoates »

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?
User avatar
jezjones29
Posts: 339
Joined: Tue Jan 31, 2006 9:43 pm
Location: Wales, UK
Contact:

Re: Variable assignment woes

Post by jezjones29 »

Code: Select all

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

Re: Variable assignment woes

Post by hayasidist »

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 »

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.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: Variable assignment woes

Post by chucky »

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.
Post Reply