Page 1 of 1

Undo Script Tool?

Posted: Tue Aug 03, 2021 7:53 pm
by J. Baker
Is there an "Undo Script" Tool for drawing tablets?

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 8:02 pm
by Lukas
Not tested this, but you could try this. Save it as LK_Undo.lua in your tools folder. If it works you can also create a redo button next to it, just change all instances of 'undo' into 'redo'

Code: Select all

-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "LK_Undo"

-- **************************************************
-- General information about this script
-- **************************************************

LK_Undo = {}

function LK_Undo:Name()
	return "Undo"
end

function LK_Undo:Version()
	return "0.1"
end

function LK_Undo:Description()
	return "Undo"
end

function LK_Undo:Creator()
	return "Lukas Krepel, Frame Order"
end

function LK_Undo:UILabel()
	return "Undo"
end

function LK_Undo:IsEnabled(moho)
	return true
end

function LK_Undo:IsRelevant(moho)
	return true
end

function LK_Undo:ColorizeIcon(moho)
	return true
end


-- **************************************************
-- The guts of this script
-- **************************************************
function LK_Undo:Run(moho)
	moho.document:Undo()
end

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 8:24 pm
by J. Baker
Thanks! I tried but it doesn't work. It shows an "unknown" icon in "Other" tools panel but when clicked, no response.

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 8:36 pm
by Lukas
J. Baker wrote: Tue Aug 03, 2021 8:24 pm Thanks! I tried but it doesn't work. It shows an "unknown" icon in "Other" tools panel but when clicked, no response.
Ah I see

Code: Select all

ScriptName = "Undo"
should have been:

Code: Select all

ScriptName = "LK_Undo"
I updated the previous post, it should run now 🙂

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 8:41 pm
by J. Baker
Thank you very much! :D

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 8:50 pm
by Lukas
No problem!

You know what, here's both undo and redo with icons, I see how this would be useful for tablets:

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 9:24 pm
by J. Baker
Here's a zip file with the LUA, PNG icons, Read Me, and Moho document...

http://www.posemotion.com/download/LK_Undo.zip

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 9:25 pm
by J. Baker
That's funny! We were thinking the same thing. I made new icons though. :D

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 10:03 pm
by Lukas
Ha 😉 nice

Re: Undo Script Tool?

Posted: Tue Aug 03, 2021 10:21 pm
by J. Baker
I renamed the "Undo" files, so that the Undo icon shows before the Redo icon in Moho. It's "LK_1_Undo" now.

Re: Undo Script Tool?

Posted: Thu Aug 05, 2021 8:25 am
by Lukas
J. Baker wrote: Tue Aug 03, 2021 10:21 pm I renamed the "Undo" files, so that the Undo icon shows before the Redo icon in Moho. It's "LK_1_Undo" now.
Actually, you can quite easy edit the order the tools are shown in by editing the _tools_list.txt file in the tools folder. So you don't have to change the names to re-order them.

Also, you can have the icons be greyed out if there's nothing to undo/redo by changing the IsEnabled function to this:

Code: Select all

function LK_Undo:IsEnabled(moho)
	if moho.document:IsUndoable() then
		return true
	end
	return false
end
(I updated/reuploaded my .zip)

Re: Undo Script Tool?

Posted: Thu Aug 05, 2021 1:56 pm
by J. Baker
Very nice! Thanks!

Re: Undo Script Tool?

Posted: Thu Aug 05, 2021 3:08 pm
by SimplSam
Lukas wrote: Thu Aug 05, 2021 8:25 am ... Actually, you can quite easy edit the order the tools are shown in by editing the _tools_list.txt file ...
The recommended way is to use the GUI: Edit > Preferences > Tool Layout (even though it is painful if you want to move a lot of stuff around!).

Re: Undo Script Tool?

Posted: Thu Aug 05, 2021 3:33 pm
by J. Baker
Interesting. Thanks!