A complete introduction to scripting for games using the versatile Lua programming language and the Core game development platform. Add an array of game coding skills to your toolbox and take your game development to new heights!
Scripts in Core are like Core Objects or templates. In this lesson you will learn some of the suprising aspects of how scripts work in Core, and how to create them.
To create a script, click the Script button in the top toolbar and select Create New Script.
The script generator will give you code for a few specific common uses, and is extremely valuable when you need a reminder of how the code should look.
Once you created a script, you can find it in the Project Content window, in the Scripts tab. If you want the script to run when you start the game, you will need to drag it from here into the Hierarchy.
Creating a script creates a new .lua file in a Scripts folder of your project directory.
To find these scripts on your computer:
Inside here you should see .lua files for each of your scripts, and .asset files that let Core treat them like an object.
When you move or duplicate scripts in Core, this does not change the script file. Instead, it creates more references to that script.
This allows you more control from a coder perspective, by not having assets that use many different but similar scripts, but can be confusing.
Even if you select Duplicate in the Scripts folder of Project Content, you are essentially creating another arrow that points back to the same script. Any changes made to the duplicate just change the original file.
You can even change the name of the script in the Hierarchy, and it will still refer to the same script, with the name you gave it originally.
If you truly want to copy a script, make a new script, and copy and paste the code into it.
You should now have a better idea of where scripts are, and how Core manages references to them. In the next lesson, you will learn how to get references game objects in your scripts, to be able to modify and