Page 2 of 2

Re: Script Recipes

Posted: Sun Mar 05, 2017 2:27 pm
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

Re: Script Recipes

Posted: Thu May 11, 2017 4:35 am
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.