Hi cassius_b,
You can get started with scripting in several different ways:
-
Micro Scripts: These are applied to the entity in the scene which may contain a model, light or camera. They bring in the id of the object they are attached to and are the general way of working. Micro scripts cannot be shared across entities unless you copy / paste the code or use the asset manager to drop a .lua file on and convert to microscript. There is
no file with the script as microscripts are saved with the scene and will be the most common script type you use alongside the scene script.
-
External Scripts: These are similar to microscripts but all the code in stored in a .lua file and must be added to the resources in order to work. These are great for sharing scripts across many entities that do the same thing. Combined with the Dynamic Properties, you can use 1 script across many entities but change the properties on each entity through the Dynamic Properties Panel and using the Custom property setups.
-
Scene Script: This is quite self explanatory. It is a script that is first to run in every scene and there is only ever one of them. This can be accessed by right clicking in the scene and bringing up the context menu. Choose "Lua - Scene Script" at the top of the menu. Use this script to control menus and level loading, but it is also possible to do what you want with it.
Note: The scene script does not contain an ID like the other entities since it is not attached to anything in the scene; its actual id is -9.
Applying a Microscript:First select the entity you wish to apply the script to and then apply/edit a Microscript by either:
- Right clicking in the scene and bring up the context menu, click on the "Lua - Add Microscript" button.
- Or attach the microscript action using the action editor which can also be found on the right click.
- Edit the script from the right click context menu "Lua - [Edit] Micro Script" or from the entities property panel where you will find the microscript action attached to the entity.
Applying an External Script:First select the entity you wish to apply the script to and then apply/edit a External Script by:
- Right Cliking in the scene and open the menu "Lua - Add External Script", then choose whether you want to create a new script or open an existing one.
- Since the External Script is
not an action, you have to remove the script from that sub menu also.
Note: Selecting the entity and dragging a lua file from the asset manager onto the entity will apply the script either as a microscript or external script of your choice.
I hope this helps you
Check out Tatties Video Tutorial: Lua Editing on the second to last row in the middle of this list of videos to see the menu being used to apply the scripts:
http://www.forum.aurasoft-skyline.co.uk/viewtopic.php?f=46&t=1107