Script Import
Other that being attached to a GameObject, ZEPETOScript can be used directly by other scripts.
You can simply import and use the ZEPETOScript the same way you would libraries or modules. In TypeScript syntax, you need to use the relative path to the ZEPETOScript file.
Considering the situation bellow, if you want to import ExtraComponent into ScriptImport, you would need to use the following syntax.
The following example is a declaration in ScriptImport.ts to call ExtraComponent.TS located in the lib folder.
👍 Tips
- It's important to specify the path correctly when importing another TS file.
- Please familiarize yourself with the relative path notation.
- ./ denotes the current directory.
- ../ denotes the parent directory, i.e., the directory one level up from the current directory.
You can access the exported functions and variables declared in the imported script by directly referencing them, like shown in the sample.
The following is a sample code showing the imported TypeScript.
Sample code for ExtraComponents.
Check out the test code output screen below.