First off, no. AS scripting has no access to "layer" scripts (that's what you mean by embedded? Correct?).
Layer scripts are only in the file format itself. AS has no access to them at all. The only way to find them is by parsing (reading) the document file itself.
-------
On script prefs:
This is the very top section of the LM translate ponts tool. The one that comes with AS not one of the modified tools. At the bottom you see the two functions that load and save the tools preference variables.
In this case it is saving what ever check boxes were selected so that the next time AS is opened this tool will have the check box values the same as when it was last opened.
Whenever you see "void" for a function it just means there is no return value. Sometimes you get a return value for instance when you "get" something it will return something, a string, an integer (0), a float (0.0) like that. When it says "void" it just means nothing is sent back or returned. You can't assign a variable the return value of a function that returns nothing, but you can set a variable to a function that does return a value so you can use it.
Setting script prefs doesn't return a value, getting script prefs returns the value for that key.
All this code is just the begging part of the tool script. Further below I've separated out the scrip prefs bit.
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LM_TranslatePoints"
-- **************************************************
-- General information about this script
-- **************************************************
LM_TranslatePoints = {}
LM_TranslatePoints.BASE_STR = 2375
function LM_TranslatePoints:Name()
return "Translate Points"
end
function LM_TranslatePoints:Version()
return "5.0"
end
function LM_TranslatePoints:Description()
return MOHO.Localize(self.BASE_STR, "Move selected points (hold <shift> to constrain, press <space> to weld, hold <alt> to disable auto-welding)")
end
function LM_TranslatePoints:Creator()
return "Lost Marble"
end
function LM_TranslatePoints:UILabel()
return(MOHO.Localize(self.BASE_STR + 1, "Translate Points"))
end
Here is where the script prefs are loaded and saved.
Code: Select all
function LM_TranslatePoints:LoadPrefs(prefs)
self.autoWeld = prefs:GetBool("LM_TranslatePoints.autoWeld", true)
self.autoFill = prefs:GetBool("LM_TranslatePoints.autoFill", false)
end
function LM_TranslatePoints:SavePrefs(prefs)
prefs:SetBool("LM_TranslatePoints.autoWeld", self.autoWeld)
prefs:SetBool("LM_TranslatePoints.autoFill", self.autoFill)
end
-- **************************************************
-- Recurring values
-- **************************************************
LM_TranslatePoints is the name of this tool. It is the "key" that is used to read in prefs. You use this so your prefs can't get mixed up with other tools.
prefs is the "inernal" AS table that holds the prefs values that were saved. So...
Code: Select all
function LM_TranslatePoints:LoadPrefs(prefs)
loads the "prefs" from AS that were saved for this tool the last time that AS was open.
Code: Select all
self.autoWeld = prefs:GetBool("LM_TranslatePoints.autoWeld", true)
.. gets the value that was saved for the "autoWeld" check box. "true" is just a default value if no prefs were saved. If that pref HAS a value that was saved then "true" is ignored. It's only used as a default.
Then the reverse happens for saving.
Code: Select all
prefs:SetBool("LM_TranslatePoints.autoWeld", self.autoWeld)
self.autoWeld is the name of the checkbox. That value is either true or false and is saved as a "bool" or boolean (true/false) value.
You can save, numbers, or strings as well as boolean values in the prefs. You should be able to save the path of the _tool_list.txt file but you may need to "escape" the characters. Not sure about that. It might not be necessary. Some of those "funky" characters like;
/\: might cause trouble.
-vern