How does "code" exactly work?
If you never wrote a single line of code in your life, these are the questions you're probably asking.
In short, programming is nothing but teaching your computer what to do and how to behave with something.
By computer, I mean anything you can execute with it, be it a game, an application, an engine, an operating system, and obviously, mods and addons for games like UT.
For instance, let's say you have a son called John and instruct him to do the following tasks everyday:
(I am not a parent, but this is the best analogy I have)
Code: Select all
- wake up at 7:00AM
- eat breakfast
- go to school
- have lunch
- more school
- go home
- have dinner
- take out the garbage
- feed the dog
- do the homework
- have fun
- go to sleep at 9:00PM
Also, the fact that he repeats the same behavior everyday makes it a "routine".
Programming is no different, it works the same way, but instead of telling John what to do, you tell a computer what to do instead.
And just like John, you must instruct it using some sort of language. If he only understands English and you try to instruct him in Chinese, he won't do anything at all and will instead ask you to speak English instead, the sole language John understands.
In programming is the same, there are a multitude of programming languages just like there are spoken languages around the world, each one with its own words, grammar, "syntax" and punctuation. But instead of Chinese or English, you have UnrealScript, Java, C++, etc, therefore in order to be able to instruct your computer to do something, you must "talk" to it in a language it understands.
So as you may have understood so far, it's pretty much like writing a list of tasks to someone, but instead of writing it in English using the English grammar, you use UnrealScript instead, and this is called "writing code" or "coding".
However, you will find that the computer is the biggest grammar extremist you will find, as while people still understand what you mean despite your grammar mistakes, the computer does not, and it will instead obligate you to write using perfectly written grammar, otherwise it won't do anything at all, as when the computer finds a grammar error in your instructions (something it doesn't understand), it will dispatch you a "syntax error" message, providing information and tips in what you did wrong.
But as long as you follow its language rules perfectly fine, the computer will do whatever you tell it to do.
To conclude this, I leave you a hypothetical example on how English could translate to UnrealScript:
English:
Code: Select all
If John has homework to do, he must do it first and only then he can go out to play
Code: Select all
if (John.hasHomework())
John.doHomeWork();
John.goOutToPlay();