User:JulienDethurens/Guide/Chapter 4: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>NXTBoy
→‎Indentation: Don't call them tabulations! No one calls them that!
>JulienDethurens
No edit summary
Line 33: Line 33:


Indented code looks much better than non-indented code. Indenting it will make it much more organized and will be extremly helpful later on, when you'll want to edit your code and understand it faster. Trust me, you should '''always''' indent code, even if you think it's not worth it.
Indented code looks much better than non-indented code. Indenting it will make it much more organized and will be extremly helpful later on, when you'll want to edit your code and understand it faster. Trust me, you should '''always''' indent code, even if you think it's not worth it.
==ReflectionMetadata.xml==
In your ROBLOX folder, there is a file called ReflectionMetadata.xml. That file controls what objects are shown in the explorer, what is their icon, what order they are shown in, as well as what objects are shown in the object browser, whether they are deprecated, their summary, etc.
The thing is, not all objects are shown in the explorer. I'm sure you've already used the InsertService, or perhaps heard about the CoreGui, or any other service like that. Yet, these don't show in the explorer, unlike the Workspace, the StarterGui, and the other basic services. And not only services, there are many other hidden objects that you do not see normally in the explorer.
You could manually edit your ReflectionMetadata.xml file to show these files. Or, you could just use a premade one. Well, you're lucky, because there's an user, Anaminus, that made his own edited ReflectionMetadata.xml file and he publishes it on an alt, he updates it often enough. Here is the alt: [http://www.roblox.com/User.aspx?ID=6449825 ReflectionMetadata].
The latest model should be the one you want. Just take it and replace your ReflectionMetadata.xml file by its contents. You can find instructions in the model.
Now, I could explain how to edit the file, but it's kind of simple, anyways, so you can figure it yourself just by looking at it. I recommend using Anaminus's ReflectionMetadata, as it allows you to see every service.
Now, you might wonder why I am talking about this even though this is a scripting tutorial. Well, in fact, when you make them show in the explorer, they also show in the object browser. What that means is that you will then see them in the object browser and you'll be able to see their properties, methods and everything, which could be helpful if you want to know about a certain property of this or that object without looking at the wiki.

Revision as of 23:18, 22 January 2012

This page talks about some subjects that could be useful to know about. You can read these at any time, there is no specific moment to read them, so you don't need to read them completely at the end. However, some of these assume you have some prerequisite knowledge, so you might only be able to understand some of these after reading a certain part of the guide.

Indentation

Indenting code means using tabs (or spaces, but I prefer tabs) to indent code, to make it more organized.

Usually, a new level of indentation is added on every new block of code, or every scope, if you prefer. Some also do it for tables and in long comments.

Here is an example of indented code (note: it will look different in the studio's script editor, because the tab width here is way too big. In the studio's script editor, the tabulations will look smaller and it will look better):

for i = 1, 50 do if math.random(5) == 3 then print(string.format("The number is %d.", i)) elseif math.random(15) == math.random(10) then print(math.random(5) + i) break end end

And here is the same code, without indentation:

for i = 1, 50 do if math.random(5) == 3 then print(string.format("The number is %d.", i)) elseif math.random(15) == math.random(10) then print(math.random(5) + i) break end end

Indented code looks much better than non-indented code. Indenting it will make it much more organized and will be extremly helpful later on, when you'll want to edit your code and understand it faster. Trust me, you should always indent code, even if you think it's not worth it.

ReflectionMetadata.xml

In your ROBLOX folder, there is a file called ReflectionMetadata.xml. That file controls what objects are shown in the explorer, what is their icon, what order they are shown in, as well as what objects are shown in the object browser, whether they are deprecated, their summary, etc.

The thing is, not all objects are shown in the explorer. I'm sure you've already used the InsertService, or perhaps heard about the CoreGui, or any other service like that. Yet, these don't show in the explorer, unlike the Workspace, the StarterGui, and the other basic services. And not only services, there are many other hidden objects that you do not see normally in the explorer.

You could manually edit your ReflectionMetadata.xml file to show these files. Or, you could just use a premade one. Well, you're lucky, because there's an user, Anaminus, that made his own edited ReflectionMetadata.xml file and he publishes it on an alt, he updates it often enough. Here is the alt: ReflectionMetadata.

The latest model should be the one you want. Just take it and replace your ReflectionMetadata.xml file by its contents. You can find instructions in the model.

Now, I could explain how to edit the file, but it's kind of simple, anyways, so you can figure it yourself just by looking at it. I recommend using Anaminus's ReflectionMetadata, as it allows you to see every service.

Now, you might wonder why I am talking about this even though this is a scripting tutorial. Well, in fact, when you make them show in the explorer, they also show in the object browser. What that means is that you will then see them in the object browser and you'll be able to see their properties, methods and everything, which could be helpful if you want to know about a certain property of this or that object without looking at the wiki.