I’m ideal, i was developing in studio for 7 years, now i’m interested in more advanced programming such as C++, but i wan’t to show you thing that allows you to do almost everything easier, soo let’s start
From start, sorry for gramatical mistakes, i’m from Poland, soo my english is not soo good, but anyways, let’s begin!
Soo, i told you about key to make everything, but what is that key? and is it something hard to understand or something you can’t acces? no, it’s one of the basics of every scripting languages, arrays and lists, also known as tables.
Soo, if you don’t know what are arrays or lists, in roblox, arrays are a list of elements, where every element have a index, a key, an acces to a element.
Example of array:
local array = {3,4,1,21,4}
print(array[1]) -- prints first index of array
of course, indexes can be something else than numbers like:
local fruits = {["Orange"] = {["Color"] = "orange",["Taste"] = "sweet"}} -- an array with fruits that contains custom index of fruits, they are shown by [index], they can be strings or numbers.
-- arrays can store other arrays
But, why we need them? they are very usefull, we can create a data structures using them, this means, store functions, variables and other stuff required to do the job
We can store real arrays using module scripts, module scripts are another topic, but for now, let’s use them as an example. For instance, we wan’t to make plant system, with different options to grow, but how? we can make array of plants, and possible states, then we using for loops to go through those and choose random combination to make unique plant.
As you can see, they are very helpfull to make systems like chance or rewards, we can store pets rarity inside, and make egg hatching too
Another important thing, without arrays, we can’t store large data easily, or even we can’t!
Data store need tables to save our data, this is the best methood.
Another, very usefull thing about arrays is creating frameworks, with module scripts, they are scripts to store data as arrays ect, we can make our function framework. For example, we wan’t to make super powers system, where players can equip different spells and abillities to fight. When player presses E key, then signal is sended to server, where it’s checked what abbility is assigned to that key, then server finds special function inside array, and fire it, functions do the rest about math, effects ect.
As you can see, arrays are very usefull for almost everything, no matter if it’s a module script or a lot of data sorted in brackets, without them, almost every big game would be there.
Here are few other examples, what you can do with them:
1. Building system
- Blocks of build are stored in array to save or load them
- Every block is in library, where there are block’s HP and stats
2. Loot system
- Loot is chosen from weight array with all items and stuff
- Loot is randomly chosen
- Loot is given to player for finishing dungeons
3. Render system
- Objects are stored on server in table
- When something changes, server sends info to client, then client checks which object
on map was affected, and then change it’s look
4. Weapon system
- Weapon stats are stored in table
- Weapon have attachements that also is a table, soo we can store them
5. Vechicle system
- Stores vechicle parts in table
- Stores modifications in table
- Stores owned vechicles with their modifications in table
I can go on with this, but those are few examples why you should learn arrays manipulation and how to use them good, thank’s for reading, bye!