
- If first things first, the very first thing you find when you open a tool/menu script is this:
Ok, and what I see is this is a global variable named "ScriptName" and it is used for EVERY Moho tool, so I understand it gets the value, in this case: "LM_AddBone", at the time the script is read/loaded by Moho and then its value gets overwritten as soon as the next tool (lm_bind_layer.lua, I guess) start to be read/loaded. So... what it's really used for? I think I can glimpse it has to do with OOP, and it is what Moho uses to internally define/create the object the tool itself is going to be after all, but I always thought the next line: "LM_AddBone = {}" was indeed all what Moho really needed to create such OOP based object, and hence my doubt. So what do you think it exactly does? My bet is ScriptName = "LM_AddBone" tells Moho to internally create an object called LM_AddBone with which a line afterwards can bound the homonym table (LM_AddBone = {}), or something so... But I'm far to be sure and I wanted to try to get some OOP concepts and understand a little better how things work under the hood regarding tools, if possible.
Code: Select all
-- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "LM_AddBone"
- And, since we are at it, one of the next things you also can find is:
And for simple curiosity... why a function? I mean, why declare a bunch of functions for only returning some strings and not a simple table entry instead like for example: LM_AddBone.Name = "Add Bone", LM_AddBone.Version = "6.0", etc. which would be simpler and equally accesible after all? Could it be for a reason/advantage, or just because it's preferred when working under the OOP paradigm for being on the safe side in case you need more functionality than what a simple variable can offer in the future or whatever?
Code: Select all
function LM_AddBone:Name() return "Add Bone" end [...] function LM_AddBone:UILabel() return(MOHO.Localize("/Scripts/Tool/AddBone/AddBone=Add Bone")) end
Or maybe because that way is unchangeable? Of course, I'm only talking here about these first super-simple "General information" functions and not about the other ones along the scripts.
Well, that's all... sorry if I went too basic with this, but I think I couldn't hold it inside anymore
