Scripting Skills 003: Making a Function and Calling it Right After

Well comings! Now that we have made a new site, I am her to make the first lesson during the update! What I do often when I script in Rbx.Lua is...

30935

I create functions, then I call them just outside its own declaration!

Well, that was bad enough. I have a specific method of making tables, or other types of variables, by function without the needs for extra variables. I will show you, after a special message from Windōws 10! WHEN YOU WANNA GET A MORE HUMAN OS, GET WINDOWS 10 OR BE GUARANTEED TO BE SWORN AT! JUST GET WINDOWS 10 FOR £0.00! IF YOU CONVERT THAT, THAT'S $0.00, OR EVEN €0.00 (What! Even Europeans get Windōws 10 for free?!)! BACK TO LESSON!

The method I use of doing this madness (what I said in big text) has no really good name, but I call it 'casting a function into itself and calling it'. Wanna see how this miracle works? Well, here it is:

This code is an excerpt of my 'Functions for Me' plugin. If you look at the code, you will see that right before the keyword 'function', there is a left round bracket. Also, on the last line, there is a right round bracket after the keyword 'end'. That means that the function created will be placed in the pair of brackets.

Since the brackets after keyword 'function' has nothing in between, the function takes no parameters. Therefore, the pair of round brackets for returning out the value for the function, if anything, is not affected by anything you put in between.

Also, you must include a 'return' statement for the function to carry on that variable to the declaration of the function. Otherwise, it will return nil and you will have your declaration as bringing in nil and you will become in hyper dead meat

Difficult?

I kinda thought so. If it wasn't, you may go ahead and skip this rest of the lesson. If so, I have some explaining to do. I will give you lot a simpler script to work with:

Go ask iiDevelopers! I am so so so so so lazy!

Snapcash