I am modding the Transform Bone tool, adding some functionality and improving usability. I want to set some parameters upon entering the script (some stuff needs to be set up, like certain bones need to be detected and labeled) and i thought i'd use the Run function for that: function LM_TransformBone:Run(moho) but it doesn't seem to work. It looks like the whole function is ignored.
Is there a way to run a function as the first thing when a tool is selected? Likewise, is there a function that can be run upon exiting the tool script, so that i can tie up some loose ends?
Functions for entering and exiting a tool script
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 306
- Joined: Thu May 13, 2010 2:01 pm
- hayasidist
- Posts: 3840
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Functions for entering and exiting a tool script
I don't know of a "formal" run once on entry / exit but ...
I think NonDragMouseMove(), DoLayout() and LoadPrefs() are each called once before the script proper gets going.
Also, I think SavePrefs() is called when the tool has come to a logical break - but I think the "end" of an input-driven script is more when you stop using it and choose something else - so it's possible that SavePrefs() might get called more often than you need.
Depending on exactly what you want to set-up / clean-up OnMouseDown() and OnMouseUp() might be just as useful??
I think NonDragMouseMove(), DoLayout() and LoadPrefs() are each called once before the script proper gets going.
Also, I think SavePrefs() is called when the tool has come to a logical break - but I think the "end" of an input-driven script is more when you stop using it and choose something else - so it's possible that SavePrefs() might get called more often than you need.
Depending on exactly what you want to set-up / clean-up OnMouseDown() and OnMouseUp() might be just as useful??
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Functions for entering and exiting a tool script
DoLayout() is always called first when a tool is selected, so that should work for your setup.
NonDragMouseMove() and LoadPrefs() are only called when Moho starts (or scripts are reloaded).
And SavePrefs() only runs when Moho exits (or scripts reloaded).
So you probably do need to do any cleanup in OnMouseUp(), like Paul suggests.
NonDragMouseMove() and LoadPrefs() are only called when Moho starts (or scripts are reloaded).
And SavePrefs() only runs when Moho exits (or scripts reloaded).
So you probably do need to do any cleanup in OnMouseUp(), like Paul suggests.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 306
- Joined: Thu May 13, 2010 2:01 pm
Re: Functions for entering and exiting a tool script
Thanks, guys! I think i'll have to try a combination of your suggestions.