In studying scripts, I've found a common beginning to the script code. Here is an example:
-- **************************************************
-- Provide Moho with the name of this scriipt object
-- ***************************************************
ScriptName = "CC_COPY_GENERIC_LAYER"
-- ***************************************************
-- General information about this script
-- ***************************************************
CC_COPY_GENERIC_LAYER = {}
function CC_COPY_GENERIC_LAYER:Name()
return "CC_COPY_GENERIC_LAYER"
end
function CC_COPY_GENERIC_LAYER:Version()
return "1.1"
end
function CC_COPY_GENERIC_LAYER:Description()
return "Copies generic layer keyframes"
end
function CC_COPY_GENERIC_LAYER:Creator()
return "Crashcore"
end
function CC_COPY_GENERIC_LAYER:UILabel()
return "CC: Copy Generic Layer v" .. CC_COPY_GENERIC_LAYER:Version()
end
-- ***************************************************
-- Recurring values
-- ***************************************************
CC_COPY_GENERIC_LAYER.firstFrameNdx = 1
CC_COPY_GENERIC_LAYER.lastFrameNdx = 1
CC_COPY_GENERIC_LAYER.tmpname = ".cc_copy_generic_layer.tmp"
I've mimicked these in my code... and wow... they do seem to change things like description and roll-over tool tip. So cool!
Problem is, I can not find ANYTHING about them in any of the documentation I have. I can find no description of 'ScriptName'. I have found nothing suggesting if you create these functions the will cause the results they do.
It is as if there is a hidden Script class. These functions are then polymorphisms to cause the actions they do.
But WHERE was I suppose to learn about this? Somebody had to learn this the first time before anyone else figured it out... where did that person get the info?
Without a description, I have some serious questions. Like, I noticed the ScriptName string is also the name of the object (whatever type it is, I have no idea without declarations or comments) is the same name.
Is the fact these have the same name 'coincidental' (i.e., most programmers just figure why not use the same name?) or is it REQUIRED (i.e., setting up ScriptName creates this object of unknown type). That is, in the code I quoted above, is setting ScriptName to CC_COPY_GENERIC_LAYER creating the object CC_COPY_GENERIC_LAYER, or is it just convenient to call them the same thing? Would calling them different things cause a problem?
And note I also included some 'incidental' variable below the apparent setup code (e.g., firstFrameNdx'). I have no idea if THESE are actually variables that already have meaning, or if they are being defined AT those lines. Without variable declarations, a description of the Script class, or any comments, it is virtually impossible to be sure what is a 'rule' and what is 'style'...
I also found another script that had this different form:
function LM_TrackCamera:UILabel()
return(MOHO.Localize("/Scripts/Tool/TrackCamera/TrackCamera=Track Camera"))
end
Note a reference to some path '/Scripts/Tool/TrackCamera'. Where is this? What created it? How did it get the 'TrackCamera' component? What is 'Localize'?
I'm guessing the difference between the two UILabel calls is the difference between a TOOL and a MENU script. Fair enough. WHERE is the description on how these two differ, what must be done differently, how to set them up in CODE (I know how to install them, that WAS in the doco...lol), etc.?
In any case, is there ANY documentation on this aspect of LUA/MOHO programming? Or have we been reduced to the days of tribesmen handing down skills by word of mouth? hehe
I also seem to always get 'moho = nil', and apparently one sets up the interface in the toolbar area AGAIN by some function you just CREATE, not CALL, implying some hidden structure that calls is as a polymorphic function.
So where IS this COMPLETE definition of MOHO, including the (what I assume is a) Script class?
I'm getting soooooo close to being able to finalize my first (and I think important) Tool... any help will be VERY appreciated!!!
PS - sorry if I'm coming off a bit anxious. But I've been programming a long time and I'm use to having a FORMAL declaration of the tools at my disposal... it makes it hard to do anything innovative if you are reduced to doing thing cook-book style. Try making a new dish by only being given recipes of other dishes... you are reduced to only using the same ingredients in the same way...see what I mean?
PPS - yes I write too much, but if I have a lot of time on my hands since I can't get past this aspect of scripting; and I'd rather be studying a document than having to ask questions here all the time...
Script header / Script class?
Moderators: Víctor Paredes, Belgarath, slowtiger
Script header / Script class?
[==Peter==]