| Home Page | Recent Changes

UnrealScript For Non-Programmers/Parts Of OOP

This page is part of the UnrealScript For Non-Programmers tutorial which is broken down into a series of pages. It may not make sense if you haven't been following this series, then again, you never know, you might gain something from it.


What an OOP Program Consists of

Objects
defined on Terminology as: "abstraction that typically is assigned clearly specified characteristics; in other words, a chunk of data with a certain class associated to it; the class describes the data structure and contains the code that deals with objects of that class".
Classes
defined on Terminology as: "type of an object, an object's class defines how an object is implemented; derived from or instantiated by an object, from which it inherits clearly defined attributes. A class can contain: static data members, objects of another class, pointers and references to types and objects of the same or another class, declarations of another class, member functions, and friend classes. All Classes are listed in the Actor browser".
Functions
defined on Terminology as: "piece of code with a defined entry point and one or more exit points".

Basically, a section of code within an object that is declared (created and defined) and does nothing until it is called from somewhere else. I assume that the "defined entry point" would be the point at which another function calls that function. At that point the program will begin to execute the code in that function in the order that the function dictates. Within the function will be at least one "exit point" which tells the program that there is no more code to execute from that function.

That exit point may be reached upon completion of every line of code in the function or as the result of a test within that function that indicates in the event of a negative result the program should skip all the rest of the code in the function and exit.

When the program exits that function it resumes executing code in the function that called it, and continues this until reaching an exit point in that function.

Variables
defined on Terminology as: "memory location with a symbolic name where a program can store information for future retrieval".

When a variable is declared (created and defined) in a program it becomes the symbolic name of a location in memory and your program can save data to that location. The data in that variable (its "value") can be read and can be changed by the program. You can declare variables in your program and name them whatever you want to name them as long as the name is not recognized anywhere else in the program as something other than a variable or as another variable (still yet, that depends on the "scope" in which that variable exists – more on scope shortly).

A variable is created as soon as it is declared, and it is initialized (set to a specific value) with its data type's empty value. I would suggest that you initialize your variables as soon as you have declared them to keep a more organized frame of mind about them. Otherwise, if you try to retrieve the value of your variable later you may get a value like "Null" or something instead of the value you could have initialized it to such as "0" or "" (a text value with no text yet) or anything else that might make more sense to you than whatever UnrealScript might put there depending on the data type you declared the variable as. An example of initializing a variable will follow later in this tutorial and you will see how that initial value can make more sense.

Scope has to do with depths of a program and at what depths a variable exists. For example if you declared a variable as "local" then its scope is only within that function or class that is created in unless it is passed to another function or class as a parameter. Therefore, if a function outside of that variable's scope was to try to look at that variable to change it or retrieve the value of it, your program would error because the variable doesn't exist to that function. If you declared the variable as "public" then you had better make sure that its name is quite unique and keep track of where all it is being changed from because it can be called from anywhere in the program, from any function in any class. If you loose track of that then your program is out of control and functions might be working on corrupted data that doesn't add up later on because the variable's value gets changed by one function while another function is working with its previous value, unaware of the change.

Just take the general idea for now. You will understand more when you start to use variables. They will become clearer also as you start to see them in the examples you will be studying here.


Related Topics

Discussion

This tut is going nowhere. I (the author) will not be contributing to it anymore, and it needs much much more. No one else is contributing to it, so it's a waste of space and an eye-sore.[DeleteME]

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In