Page 2 of 5

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 9:19 am
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 9:39 am
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!

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 10:35 am
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 12:49 pm
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

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 2:12 pm
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

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 2:24 pm
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 2:32 pm
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!

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 3:57 pm
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 4:01 pm
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 4:11 pm
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.

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 4:30 pm
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.)

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 4:51 pm
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

Re: How to I lock a layer?

Posted: Sat Jun 26, 2021 7:18 pm
by synthsin75
Just added Sam's awesome mod to the updated link:
https://www.dropbox.com/s/di9qqlq4mho4k ... r.zip?dl=0

Re: How to I lock a layer?

Posted: Sun Jun 27, 2021 1:34 am
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

Re: How to I lock a layer?

Posted: Sun Jun 27, 2021 1:57 am
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.