Proper pathing is a much debated thing in the TD community. The easiest and most straightforward way is probably to use global op shortcuts, or parent shortcuts if the script is being run by a child operator..
Also, FWIW, the nicest place to put scripts is in extensions (see wiki) not just sitting in a DAT
@art3misop('feedback1') is a relative path, that is, relative to the network itâs in. To be able to trigger this from anywhere youâd need an absolute path:
op('/project1/someplace/feedback1')
(this assumes you have a COMP node called someplace).
To invoke the script that lives in the Text DAT, you could make a button to invoke it. Basically you need some kind of invoking trigger, e.g. a button press, a script DAT, a Parameter Execute DAT.
For simplicity, make a Button COMP, set it to âmomentaryâ. Put down a Parameter Execute DAT. Set the ParamExec DATâs OPs field to the new button, set the Parameters par to value0, and leave only Value Change toggled to on. In the docked parexec1 script, set the onValueCHanged() to:
def onValueChange(par, prev):
# use par.eval() to get current value
if par.eval() == 1:
op('/project1/someplace/text1').run()
return
This will run the entire script in the Text DAT. Of course if youâre only need is to pulse that one parameter, just put that code directly in the parexec1.
Indeed I find Iâm creating the same Script DATs in multiple places. Other than pointing all of them to the same Text DAT for their code, it sounds like extensions might be a way to go.
What would the callbacks of a Script DAT (or Parameter Execute DAT) look like if the meat of the script was in an extension?
Is there a way to override or edit the template code that gets created for the Script DATâs callaback Text DAT?
Assuming your script DAT is inside a custom component with parent shortcut âScryptoâ, youâd just have a line like this in your onCook callback: parent.Scrypto.OnCookScript(whateverArgs)
Then you put all the code in the OnCookScript function in the extension.
If you want to access OnCookScript globally (and just have one custom comp) you could use a global OP shortcut instead and your call would look like this: op.Scrypto.OnCookScript(whateverArgs)
Obviously you donât have to use these example names. Please donât You do have to capitalize the function for it to be âpromotedâ to the component object though.