In this part we want to talk about conditions and their usage in computer programming. But without any actual work in MEL. If you are not familiar you can use our previous tutorials on MEL. Conditionals are a ways completing a super complex action in a computer programming language. It can does simple jobs from printing a text to most complex jobs such as simulation of particles and other dynamic systems. Conditions are exactly driven out of real life. The only big difference between real life and programming in terms of conditional is that many tasks in real life are done habitually, unconsciously while in computer there is no task to be done out of order and design of a super conscious computer, however in a limited scope.
Let me give you an example of a real world action which include step by step of conditionals. You want to eat a piece of bread with a bunch of fried potatoes. Now? Let’s begin the scenario:
You go to refrigerator to pick a slice of bread. You open the door and find that you have already run out of bread. So what to do? there are a plateful of french fried. Then this happens:If I do have bread, I would eat french fried with bread
But If I don’t have bread, I do go to super market to buy.
(now that I go)
if I have money I would but a bottle of soda
(now that I wanna but)
If there is black soda I would buy
but if it does not have I would b the orange one!
but If I don’t have I would not buy
This is the very usage of it in programming, too. But instead of “but” we use “else”.
For instance if you want to check if the user has entered the value or not, and if not, then report him an error, you must use conditionals.
If the sphere’s radius is less than 1 color it red, if it is greater than one, leave the color as it is.
If the character is in a distance longer than 100 units from camera, then move it 50 frames in second, if it is in less than 100 units from the camera move it in 25 frames in second.
This was a very brief overview of what conditionals in computer programming would indeed do. In later tutorials we would go through it practically.