Scripting: External Script

This script resides on your hard drive and can be referenced by any object from any scene. Great for when you want to make an update to the script then all objects referencing this script will also update. Downside is that all scripts remain the same and if you break the script all objects will be broken but you can apply customization with the dynamic properties for variety of uses. These external scripts are used a lot in the game objects, where systems can develop and grow then all projects using them are automatically updated.

Add External Script

The external script is accessed in a similar way to the micro script. As this script is file based you can either load an existing file or create a new one from scratch. So let’s take a look at how to use this script type.

a) Select the object to attach the external script to. Then [RMB] to open the context menu and choose “Lua – Add External Script” This will show a menu roll out with a couple of options.



External Script Options

Depending upon your choice you will open a file dialog for you to choose a script or if you selected the “New Script” option for you to create a new script. Then this script will be opened in the script editor for you. Once opened you can make your changes and press the save icon to save this script back to a hard drive location.

Help My New script failed!

When a script is created it needs to be added to the resources system. This is done for you automatically but will throw up a box asking you do you want to add this script…. if you clicked no then it will be ignored but this will prevent you script form running correctly. If this is the case for you try this:
Go the scripts folder (Where you saved your script) in Asset Manager and click on the folder to display its contents. Now if it’s added to resources nothing will happen, except showing the folder contents. If it’s not then then a Message box will show.

Removing the Script

Removing the script is as easy as clicking on the last option in the external scripts context menu “Remove Script”