Hi all, I'm new to scripting in Lua and especially Moho. I'm not sure I understand yet, even after looking at some examples, of how to get a button in a SimpleDialog to call a function.
Some context: I'm trying to write a simple script (unless something like this exists already) to replace text in bone names or swap a bone name suffix from L <-> R. I've actually tried to repurpose the framework of an existing script (specifically Rename Smart Bone), but my code crashes Moho when I click OK. Could someone help me understand what happens after SimpleDialog:OnOk() is called? Is the rest of Run() executed? I'm trying to understand where to put my code block that iterates over bones and replaces text. Preferably, I'd like to have this in a function called by a dedicated button.
While I'm asking this question, I'm curious about something else - is there a way to send scripts to Moho for execution from an IDE? Or is the only option for script development to keep closing / re-opening Moho?
LM.GUI Button call a function?
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 26
- Joined: Mon Feb 20, 2017 9:23 pm
- Contact:
-
- Posts: 26
- Joined: Mon Feb 20, 2017 9:23 pm
- Contact:
Re: LM.GUI Button call a function?
Maybe never mind the first question Think I'm finding my answers here - https://mohoscripting.com/script_structure
Still curious if there's a better method for script development than opening / closing Moho?
Still curious if there's a better method for script development than opening / closing Moho?
Re: LM.GUI Button call a function?
Do you mean for loading/updating scripts? If so, Shift+Ctrl+Alt+L will do that.swingsoneto wrote: ↑Tue Aug 22, 2023 9:58 pm Still curious if there's a better method for script development than opening / closing Moho?
Can't help with the other stuff, but hopefully, someone with a lot more scripting experience than I have will stop by shortly.
D.R. Greenlaw
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion
Re: LM.GUI Button call a function?
You can use the tool at: https://mohoscripting.com/new_script to help quickly generate script structures.
The SimpleDialog does return to Run after OK & Cancel - but you will need to use HandleMessage if you want to respond to any other button click. The tool above - creates all of that.
For IDE to Moho roundtrip - I use keyboard macros to Save Doc, Switch to Moho, Reload Moho (as shown by @Greenlaw), combined with an Elgato Stream Deck - but any keyboard macro tool should help.
The SimpleDialog does return to Run after OK & Cancel - but you will need to use HandleMessage if you want to respond to any other button click. The tool above - creates all of that.
For IDE to Moho roundtrip - I use keyboard macros to Save Doc, Switch to Moho, Reload Moho (as shown by @Greenlaw), combined with an Elgato Stream Deck - but any keyboard macro tool should help.
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
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
- synthsin75
- Posts: 9981
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: LM.GUI Button call a function?
I don't know why I never thought to write a macro to do that. Probably save on me from miskeying reload scripts and crashing Moho....although that may be more about some of the hacks I use in several of my scripts.
- 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: 26
- Joined: Mon Feb 20, 2017 9:23 pm
- Contact:
Re: LM.GUI Button call a function?
Thank you! I just found that tool yesterday after posting this I noticed that the default HandleMessage function was responding to button clicks, so I was able to start piecing it together. That tool's super helpful. Thank you for the tip about macros, I'll look into that!SimplSam wrote: ↑Wed Aug 23, 2023 3:29 am You can use the tool at: https://mohoscripting.com/new_script to help quickly generate script structures.
The SimpleDialog does return to Run after OK & Cancel - but you will need to use HandleMessage if you want to respond to any other button click. The tool above - creates all of that.
For IDE to Moho roundtrip - I use keyboard macros to Save Doc, Switch to Moho, Reload Moho (as shown by @Greenlaw), combined with an Elgato Stream Deck - but any keyboard macro tool should help.
-
- Posts: 26
- Joined: Mon Feb 20, 2017 9:23 pm
- Contact:
Re: LM.GUI Button call a function?
Oh, for real? I had no idea that was there; is that even a menu item anywhere, or is it just hidden away as a shortcut?Greenlaw wrote: ↑Tue Aug 22, 2023 10:03 pmDo you mean for loading/updating scripts? If so, Shift+Ctrl+Alt+L will do that.swingsoneto wrote: ↑Tue Aug 22, 2023 9:58 pm Still curious if there's a better method for script development than opening / closing Moho?
Can't help with the other stuff, but hopefully, someone with a lot more scripting experience than I have will stop by shortly.
Re: LM.GUI Button call a function?
Hi,
It's a little hidden, I guess. Look at page 539 of the User Manual, under Main Window shortcuts:
Alt Shift Ctrl L - Reload Tools And Brushes.
I probably learned that from someone here in this forum years ago. Note that it changed briefly to something else during the 13.0 cycle, but reverted to Alt+Shift+Ctrl+L again with 13.5.
Hope this helps.
It's a little hidden, I guess. Look at page 539 of the User Manual, under Main Window shortcuts:
Alt Shift Ctrl L - Reload Tools And Brushes.
I probably learned that from someone here in this forum years ago. Note that it changed briefly to something else during the 13.0 cycle, but reverted to Alt+Shift+Ctrl+L again with 13.5.
Hope this helps.
D.R. Greenlaw
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2020 Edtion