Script Recipes

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

Re: Script Recipes

Post by strider2000 »

If you were requesting/suggesting I simply add these two lines

Code: Select all

   msPrintSwitchLayers.moho = moho
   msPrintSwitchLayers:ProcessTopLayers()

that was unclear to me. I would have gladly done it, because I was only seeking to explain what I am meant by recipe when I opened the thread, and why I use self.moho in my code. In no way am I seeking to deny ways to improve things. I'll leave my previous recipe post unedited, so readers can follow your suggestions for improvement.

For readers, here's the actual call I have in my running script

Code: Select all

function msPrintSwitchLayers:Run(moho)
	self.moho = moho
	self:ProcessAllTopLayers()
end
I get moho from the Run method. I assign it to self, because it allows me to access moho, via self.moho, in any of the methods in msPrintSwitchLayers.lua without passing moho as a parameter. For more information about why I do that you might find these links helpful
User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

Re: Script Recipes

Post by strider2000 »

Stan wrote:Yeah, I was thinking of having a library of code snippets on mohoscripting.com for a long time.
Cool Stan. I see you added your snippet http://mohoscripting.com/index.php?show=code_snippets :) I don't know how many others have seen it, but I appreciate it :) Thanks.
Post Reply