Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Gamemaker Essentials

You're reading from   Gamemaker Essentials Learn all the essential skills of GameMaker: Studio and start making your own impressive games with ease

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784396121
Length 154 pages
Edition 1st Edition
Arrow right icon
Toc

Scripts


Scripts in GameMaker are blocks of code not directly related to any object in a project. A script is accessible by all objects in a project at any time and allows developers to create their own functions using GML.

Scripts allow developers to create complex calculations and have the answer returned and stored in a variable as an end result. Scripts are also commonly used when multiple objects are meant to behave the same way. Instead of typing up the same code in every object, a script can be used and run in each object.

Let's take a look at scripts and how they are used.

Creating a script

The first step to using a script is creating one. To do this, click on the icon in the main toolbar that looks a bit like a new page with a play button on it .

This will create a new script and display the code editor so we can start writing code. Before typing anything, we need to know what we want this script to do. Will it be a simple piece of code? Will it need to return a value at the end? How...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images