The CreatorCon Call for Content is officially open! Get started here.

More in-depth API name in script include

Ali Usman
Tera Contributor

I want "a set of scripts" in script include into a group, such as I want to have a global.cars.script1 and global.cars.script2. Similar I want to have global.trucks.script1 and global.trucks.script2 as an API name (Please forgive my bad example but you get an idea). 

find_real_file.png

Is there a way to do this? I want to have the API Names clean so If I am looking into a set of scripts I know where to go and when I want to call them instead of all of them under 'global' with different names?

1 ACCEPTED SOLUTION

AFAIK, it's not supported.

It's possible to define a function within the Script Include function or initialize another class within a function but this will be different.

var NestedFunctionTest = Class.create();
NestedFunctionTest.prototype = {
    initialize: function() {},
    parentFunction: function(name) {
		var temp = 'parent function';
		if (name == 'childFunction')
			return childFunction();
		
        function childFunction() {
            return 'child';
        }
		return temp;
    },
    type: 'NestedFunctionTest'
};

View solution in original post

4 REPLIES 4

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Ali,

Will using underscore characters "_" be OK?

find_real_file.png

Hey @Hitoshi Ozawa  Yep I can use workarounds like this or creating a class functions inside the class will be similar thing, but was looking for something solid like global scope, then package scope and then scripts in the package 🙂 But I think this might not be possible.

AFAIK, it's not supported.

It's possible to define a function within the Script Include function or initialize another class within a function but this will be different.

var NestedFunctionTest = Class.create();
NestedFunctionTest.prototype = {
    initialize: function() {},
    parentFunction: function(name) {
		var temp = 'parent function';
		if (name == 'childFunction')
			return childFunction();
		
        function childFunction() {
            return 'child';
        }
		return temp;
    },
    type: 'NestedFunctionTest'
};

Ali Usman
Tera Contributor

Hey @Hitoshi Ozawa  Yep I can use workarounds like this or creating a class functions inside the class will be similar thing, but was looking for something solid like global scope, then package scope and then scripts in the package 🙂 But I think this might not be possible.