Friday, August 23, 2013

UnrealScript Basic Syntax: Variable Types And Objects

UnrealScript Basic Syntax: Variable Types And Objects

(covers how to create variables, sketching advance variable types how to create class instance (objects) and other few things)

  • Unrealscript is not case sensitive.
  • You can Declare Variables outside "DefaultProperties" but you cannot initialize them.(Learn more about default property block go here)
  • You must Initialize your Variables in the DefaultProperties.

Creating primitive variables: Unreal support the primitive types string, Boolean, integer, float
  • Syntax: var [keyword] type name OR local [keyword] type name
  • About:
    •  Replace type to int or bool or string or float as you want & named it how ever you want. (typical variable naming conversion applied same with unrealscript such as you can't begging the name with special letter like *&^%$# or a number and etc). 
    • If variable use local keyword it local to the function so it declare inside a function and it can be initialize inside the function. if you use var key word it is global. you can access it in another class or method, if it is not declared as private or public. key word section not necessary if you aren't define it it will be automatically public. 
  • Examples: 
    • var int pens; //pens can hold only whole numbers such as 1, 2, 3, ... it cannot hold 1.2
    • var float waterLiter; //It can numbers whole numbers and floating point numbers like 3.123 
    • var string sayHello; // It can hold letters like 'hello world'
    • var bool isItRain; // It can only hold 2 values "True" Or "False" 

Advance variables: Arrays, Dynamic Arrays, Enumerations, Structures, Vectors, Rotators

  • Some Advance Variables are Odd in Unrealscript
  • Deference between Arrays and Dynamic Arrays is when we declare an Array we specify the Array size. but if a situation that can not specify exactly how long the array is, we declare it as a dynamic array, dynamic array can change there length while running.
Create Class Instance also called as Objects:
  • In unreal script object can be created in two ways ( commonly use two ways but there may be more)
  1. Create class type variable and initialize it inside DefaultProperties (learn more about DefaultProperties go here)
  2. All done Inside DefaultProperties. class properties can be change in this way, example if you wan to override something before initialize. it is possible.
FIRST WAY: Create class type variable and initialize it inside DefaultProperties
  • Declare the Object (Syntax): var class<class_name> object_name;
  • Initialize the object (Syntax): object_name=class'class_name'
class Test extends Object;


//Declare the class type object
var class<class_name> object_name;

defaultproperties

{
     //Initialize the Object
     object_name=class'class_name'

}


SECOND WAY:  overriding something possible in this way.
  • Syntax Example:
Begin Object Class=class_name Name=object_name
    //override sample(0) variable     
    Samples(0)= 000.323
      End Object

      //replace "class_name" with the actual class name
      //and "object_name" is the name of the object variable

      This post is not fully completed. It is still updating!
      Correct me if i am wrong about anything. Thank you!

      No comments:

      Post a Comment