Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
UScript Tutorial.doc
Скачиваний:
4
Добавлен:
01.09.2019
Размер:
634.37 Кб
Скачать

FlakCannon Class Declaration

class FlakCannon expands Weapon;

Not too difficult, is it? All it consists of is the word "class", followed by the name of the class, then the word "expands" followed by the name of the parent class and a semicolon. The semicolon is just a way of telling the compiler that the statement is finished. Just about everything you write in UnrealScript will need a

semicolon at the end, so get used to it. Now, when writing code in UnrealEd, you won't have to worry about

the class declaration much, since UnrealEd will automatically generate this line of code when you create a new class. However, if you write code in text-based .uc files outside of UnrealEd, you will need to write the class declaration manually.

I n t r o d u c i n g : V a r i a b l e s

If you've ever done any programming before, I'm sure you have a firm concept of what a variable is, and what they're used for. If this is the case, you should probably skip down to the "Types of Variables" section below. If the question What the hell is a variable? is floating around in the back of your mind (or the front of it, for that matter), though, you'll want to keep reading. Technically speaking, a variable is a location in your computer's memory that stores a piece of information. This information can be of many different types, such as numbers or words. Variables come in handy all the time while writing code. For example, let's say you're making a new weapon, and you want it to charge up in alt-fire. To accomplish this, you could use a variable. When the player presses alt-fire, have Unreal add to this variable. Then, when the player presses fire, have Unreal fire a projectile that does a varying amount of damage according to the value that was stored in your charge variable.Damn, I didn't do a very good job explaining that, did I? Well, hopefully you're able to grasp the concept of variables without much help from me. I've found that most people don't have much trouble with it. It's just one of those things that naturally makes sense.

T y p e s o f V a r i a b l e s

If you've done any programming in BASIC, or a similar language, you've probably become accustomed to using variables a certain way. Namely, not having to declare them. Declare them, you ask? Yes, declare them. Variables in UnrealScript, just as in C++, Java, and JavaScript, must be declared before you can use them. Basically, you have to let Unreal know that you are going to use a new variable. The basic variable declaration syntax in UnrealScript looks like this:

The Variable Declaration

var [vartype] [varname];

Pretty straight-forward. First comes the keyword "var", then the type of variable you are declaring, and finally the name of the variable. Variables must be declared at the beginning of a class, after the class declaration and exec commands, but before any functions. There are many different types of variables, ranging from numbers, to letters and words, to "true" or "false" values. The types available in UnrealScript are as follows:

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]