The resource loading... loading...

Template Library Parameters

Template library can also set its own interface parameters, which are used in the form of global variables in the code of template library. For example, we set the parameters of a template class library:

Template parameters

Variable name of the parameter in the strategy code Name of the parameter displayed on the strategy screen Type Default value
param1 param1 number 99
$.SetParam1 = function(p1) {
    param1 = p1
}

$.GetParam1 = function() {
    Log("param1:", param1)
    return param1
}
def SetParam1(p1):
    global param1
    param1 = p1

def GetParam1():
    Log("param1:", param1)
    return param1

ext.SetParam1 = SetParam1
ext.GetParam1 = GetParam1
void SetParam1(float p1) {
    param1 = p1;
}

float GetParam1() {
    Log("param1:", param1);
    return param1;
}

Template class library code for testing param1 parameters:

function main () {
    Log("Call $.GetParam1:", $.GetParam1())
    Log("Call $.SetParam1:", "#FF0000")
    $.SetParam1(20)
    Log("Call $.GetParam1:", $.GetParam1())
}
def main():
    Log("Call ext.GetParam1:", ext.GetParam1())
    Log("Call ext.SetParam1:", "#FF0000")
    ext.SetParam1(20)
    Log("Call ext.GetParam1:", ext.GetParam1())
void main() {
    Log("Call ext::GetParam1:", ext::GetParam1());
    Log("Call ext::SetParam1:", "#FF0000");
    ext::SetParam1(20);
    Log("Call ext::GetParam1:", ext::GetParam1());
}

Reference the strategy code of the template class library example above and use the export function of the template class library to get the parameter param1 and modify the parameter param1.

Export function of template library Reference Template Library