How to I lock a layer?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
SimplSam
Posts: 1049
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: How to I lock a layer?

Post by SimplSam »

synthsin75 wrote: Sat Jun 26, 2021 9:10 am WT?! What text editor are you using that can handle emojis, and since when does Lua interpret them?!
I primarily use VSCode, but most editors (even Notepad support this character). I think this is more about Unicode support rather than Emoji. According to: https://unicode-table.com/en/1F512 this lock-thing has been around in Unicode since 2010.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How to I lock a layer?

Post by synthsin75 »

I had no idea Moho Lua supported UTF-8 encoding. I've always used ANSI.
It doesn't accept Unicode or Unicode Big Endian here.

Thanks for showing me something new!
User avatar
hayasidist
Posts: 3531
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How to I lock a layer?

Post by hayasidist »

there are two eye-openers in that for me.

I mindlessly use string.sub(s,i) ... seeing s:sub(i) had me reaching for the manual and yep - clear as day: "The table string ... sets the __index field [to] point to the string table. Therefore ... string.byte(s,i) can be written as s:byte(i)." Just never read that part!

Layer names in Moho can use unicode "graphics"! Once again, a glimpse of the blindingly obvious - but with my head stuck firmly in "names use letters from the alphabet" all of a sudden the opportunity to include a graphic in the name opens up possibilities -- some users have added text to show Smart Mesh, Reference, Animated ... layers.
User avatar
SimplSam
Posts: 1049
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: How to I lock a layer?

Post by SimplSam »

hayasidist wrote: Sat Jun 26, 2021 10:35 am I mindlessly use string.sub(s,i) ... seeing s:sub(i) had me reaching for the manual and yep - clear as day: "The table string ... sets the __index field [to] point to the string table. Therefore ... string.byte(s,i) can be written as s:byte(i)." Just never read that part!
You can also use this with plain strings - if you enclose them in brackets.

Code: Select all

print( ("Hello"):upper() )
print( ("Hell%.2f"):format(0) )
results

Code: Select all

HELLO
Hell0.00
Last edited by SimplSam on Sat Jun 26, 2021 5:33 pm, edited 1 time in total.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
striker2311
Posts: 224
Joined: Wed Aug 26, 2020 3:55 pm

Re: How to I lock a layer?

Post by striker2311 »

SimplSam wrote: Sat Jun 26, 2021 6:52 am HeHe .. I made a small hack to this a while ago, to include a lock symbol on the locked layer.

Image

Code: Select all

function Syn_LockLayer:Run(moho)
	local lock_prefix = "🔒 " -- len == 5
	for i=0, moho.document:CountSelectedLayers()-1 do
		local layer = moho.document:GetSelectedLayer(i)
		layer:SetLocked(not layer:IsLocked())
		local name = layer:Name()
		if (layer:IsLocked()) then
			layer:SetName(lock_prefix .. name)
		else
			if (name:sub(1,5) == lock_prefix) then
				layer:SetName(name:sub(6))
			end
		end
	end
end
I don't know from when but I seriously just love to see Moho and its community grow and to be honest I never felt this way towards any other software or community. It kinda surprises me whenever I see any update or new script I gets a genuine smile . :D
User avatar
striker2311
Posts: 224
Joined: Wed Aug 26, 2020 3:55 pm

Re: How to I lock a layer?

Post by striker2311 »

SimplSam wrote: Sat Jun 26, 2021 12:49 pm
hayasidist wrote: Sat Jun 26, 2021 10:35 am I mindlessly use string.sub(s,i) ... seeing s:sub(i) had me reaching for the manual and yep - clear as day: "The table string ... sets the __index field [to] point to the string table. Therefore ... string.byte(s,i) can be written as s:byte(i)." Just never read that part!
You can also use this with plain strings - if you enclose them in brackets.

Code: Select all

print( ("Hello"):upper() )
print( ("Hell%.2f"):format("0") )
results

Code: Select all

HELLO
Hell0.00
Ohh I still think it doesn't accept utf-8 also :(
In my computer it is still showing unexpected character 239 even when I have saved it in UTF-8 format through notepad.
User avatar
Víctor Paredes
Site Admin
Posts: 5664
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: How to I lock a layer?

Post by Víctor Paredes »

SimplSam wrote: Sat Jun 26, 2021 6:52 am HeHe .. I made a small hack to this a while ago, to include a lock symbol on the locked layer.
Image
Haha! That is amazing!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
Greenlaw
Posts: 9273
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: How to I lock a layer?

Post by Greenlaw »

Ha ha! Seeing the icon is pretty cool! :D

I think this tool or something like it should be native. It's especially useful for Reference layers where it's currently too easy to edit the layer unintentionally.
User avatar
striker2311
Posts: 224
Joined: Wed Aug 26, 2020 3:55 pm

Re: How to I lock a layer?

Post by striker2311 »

Greenlaw wrote: Sat Jun 26, 2021 3:57 pm Ha ha! Seeing the icon is pretty cool! :D

I think this tool or something like it should be native. It's especially useful for Reference layers where it's currently too easy to edit the layer unintentionally.
Hey Greenlaw, is this workable I mean is your layer panel showing that icon?
I have saved the lua file with UTF-8 but even then that icon is not showing except that I think everything is working fine.
User avatar
Greenlaw
Posts: 9273
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: How to I lock a layer?

Post by Greenlaw »

Sorry, I was responding to seeing the image. Will try this hack on my computer in just a minute.

If this feature ever gets the native treatment, I'd like to see it added as a column in the Layers Window, like the lock column in After Effects, or maybe as right-click command. Either works for me, but having both as options would be great.

For example, with the current Quick Settings, I like to disable the Quick Settings column on my computer (to make room in the window) and use the right-click version instead, but I imagine many users may prefer the column version. Having a Lock column and right-click version seems like a natural enhancement in the Layers window.
User avatar
Greenlaw
Posts: 9273
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: How to I lock a layer?

Post by Greenlaw »

Follow up: Yes, the lock icon hack works here, both as a button and menu script.

How are you adding SimplSam's hack? The code replaces the 'LOCKED text' function at the bottom, so you should comment out the original code or remove it. (Do this to a copy of course.)

I didn't have to do anything extra, it just worked. (Running on latest Windows 10 here.)
User avatar
striker2311
Posts: 224
Joined: Wed Aug 26, 2020 3:55 pm

Re: How to I lock a layer?

Post by striker2311 »

Greenlaw wrote: Sat Jun 26, 2021 4:30 pm Follow up: Yes, the lock icon hack works here, both as a button and menu script.

How are you adding SimplSam's hack? The code replaces the 'LOCKED text' function at the bottom, so you should comment out the original code or remove it. (Do this to a copy of course.)

I didn't have to do anything extra, it just worked. (Running on latest Windows 10 here.)
OK I had set to open every lua file in notepad in default. Now I have changed it to my VS code now it is working fine in my Moho too. I think the program in which we opens up lua also affects lua file to some extent.

After seeing many types of scripts now I think I should also start to learn how to write a script. :) :D
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How to I lock a layer?

Post by synthsin75 »

Just added Sam's awesome mod to the updated link:
https://www.dropbox.com/s/di9qqlq4mho4k ... r.zip?dl=0
User avatar
DK
Posts: 2854
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: How to I lock a layer?

Post by DK »

I added that yesterday thanks Sam and what a great script Wes! Only thing slightly annoying is having to go back to the menu to disable the lock. Could a double click be used to disable it instead?
Cheers
D.K
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How to I lock a layer?

Post by synthsin75 »

DK wrote: Sun Jun 27, 2021 1:34 am I added that yesterday thanks Sam and what a great script Wes! Only thing slightly annoying is having to go back to the menu to disable the lock. Could a double click be used to disable it instead?
Cheers
D.K
Like double clicking a locked layer, unlocks it? Maybe, but installing it as a tool, should be pretty handy.

I could probably double-click unlock on frames > 0, since I'm already keeping from selecting locked layers after frame 0.
Post Reply