Anyone Here Know Anything About UnrealScript?

Started by
4 comments, last by wildpins 12 years, 9 months ago
Hello guys.

I've only made a few posts here while I was (well, I'm still in the process of practicing) learning C++.

I have since made the jump to using the Unreal Development Kit for my game projects. So far the Syntax is very similar to C++ which is helpful; however, I'm having a little problem

Note: The reason I havn't posted to the Unreal Forums is that my account is currently not active and i am waiting in a Moderator Queue to allow me onto the forums.

So I was wondering if anyone here knows Unreal Script and would be willing to answer a question I have.


In C++ class functions and members can be accessed by the member operator '.'

This seems to not be the case with unreal script.

I'm trying to figure out how to call class member functions and access class members in Unrealscript for use with my HUD.

Anyone know how accessing other classes works in Unreal Script?
Advertisement

Hello guys.

I've only made a few posts here while I was (well, I'm still in the process of practicing) learning C++.

I have since made the jump to using the Unreal Development Kit for my game projects. So far the Syntax is very similar to C++ which is helpful; however, I'm having a little problem

Note: The reason I havn't posted to the Unreal Forums is that my account is currently not active and i am waiting in a Moderator Queue to allow me onto the forums.

So I was wondering if anyone here knows Unreal Script and would be willing to answer a question I have.


In C++ class functions and members can be accessed by the member operator '.'

This seems to not be the case with unreal script.

I'm trying to figure out how to call class member functions and access class members in Unrealscript for use with my HUD.

Anyone know how accessing other classes works in Unreal Script?


Have you taken a look at the Development\Src\UTGame folder? Normally one would advise not looking at source code when learning to do something, however in the circumstance where you are working in an existing engine and trying to make things work in that engine, looking at existing code in my opinion is very valuable (The same constraints they have to make to work with the Unreal engine are probably the same constraints you will have).

Also the '.' operator is used in that manner in Unreal Script.

For instance from UTPlayerController, line 837 (roughly):


reliable server function ServerProcessSpeechRecognition(SpeechRecognizedWord ReplicatedWords[3])
{
local array<SpeechRecognizedWord> Words;
local int i;
local UTGame Game;

Game = UTGame(WorldInfo.Game);
if (Game != None)
{
for (i = 0; i < 3; i++)
{
if (ReplicatedWords.WordText != "")
{
Words[Words.length] = ReplicatedWords;
}
}

Game.ProcessSpeechRecognition(self, Words);
}
}


Main thing to note is that variables (in this case local variables) must be declared and initialized on two separate lines (as far as I know). Also you need to typecast to the appropriate type containing your methods. such as convertedInstance = MyClass(instanceToConvert) ect. Here we see Game = UTGame(WorldInfo.Game) .

[quote name='bls61793' timestamp='1310495674' post='4834430']
Hello guys.

I've only made a few posts here while I was (well, I'm still in the process of practicing) learning C++.

I have since made the jump to using the Unreal Development Kit for my game projects. So far the Syntax is very similar to C++ which is helpful; however, I'm having a little problem

Note: The reason I havn't posted to the Unreal Forums is that my account is currently not active and i am waiting in a Moderator Queue to allow me onto the forums.

So I was wondering if anyone here knows Unreal Script and would be willing to answer a question I have.


In C++ class functions and members can be accessed by the member operator '.'

This seems to not be the case with unreal script.

I'm trying to figure out how to call class member functions and access class members in Unrealscript for use with my HUD.

Anyone know how accessing other classes works in Unreal Script?


Have you taken a look at the Development\Src\UTGame folder? Normally one would advise not looking at source code when learning to do something, however in the circumstance where you are working in an existing engine and trying to make things work in that engine, looking at existing code in my opinion is very valuable (The same constraints they have to make to work with the Unreal engine are probably the same constraints you will have).

Also the '.' operator is used in that manner in Unreal Script.

For instance from UTPlayerController, line 837 (roughly):


reliable server function ServerProcessSpeechRecognition(SpeechRecognizedWord ReplicatedWords[3])
{
local array<SpeechRecognizedWord> Words;
local int i;
local UTGame Game;

Game = UTGame(WorldInfo.Game);
if (Game != None)
{
for (i = 0; i < 3; i++)
{
if (ReplicatedWords.WordText != "")
{
Words[Words.length] = ReplicatedWords;
}
}

Game.ProcessSpeechRecognition(self, Words);
}
}


Main thing to note is that variables (in this case local variables) must be declared and initialized on two separate lines (as far as I know). Also you need to typecast to the appropriate type containing your methods. such as convertedInstance = MyClass(instanceToConvert) ect. Here we see Game = UTGame(WorldInfo.Game) .
[/quote]


Well I have seen many people typecasting variables from other classes but I'm not exactly sure how it works.

Basically speaking, why can't (using my example)

TestGamePawn.getwaterlevel();


why would this not call the function 'getwaterlevel()' from the TestGamePawn class?

EDIT: Comparing it to C++ shouldn't it work like this:


//Class Declaration
class TestGamePawn
{
int charwaterlevel;
Public:

int getwaterlevel()
{
return charwaterlevel;
}

}

//Main
int main()
{
int i;
//Calling the class function via member operator.
i =TestGamePawn.getwaterlevel();
}
Your sample C++ code is wrong... you call functions from instances of Classes...

so something like

TestGamePawn pawn;
pawn.getwaterlevel();

you could also do:

TestGamePawn* pPawn = new TestGamePawn();
pPawn->getwaterlevel();

OR you make the function "static" and in that case you would use:


TestGamePawn::getwaterlevel() instead of TestGamePawn.getwaterlevel()



EDIT: corrected wording about static function
The same principle applies to UnrealScript...

notice how inside the function it does this:

[color="#1C2837"][color="#000088"][color="#000088"]local[color="#000000"] [color="#660066"][color="#660066"]UTGame[color="#000000"] [color="#660066"][color="#660066"]Game[color="#666600"][color="#666600"];


it's declaring an instance of the UTGame class... and it calls functions using the Game variable. It doesn't call functions using the UTGame class.


EDIT: correction...

[color="#000088"][color=#000000]


[color=#1C2837][size=2][color="#000088"][color="#000088"]local[color="#000000"] [color="#660066"][color="#660066"]UTGame[color="#000000"] [color="#660066"][color="#660066"]Game[color="#666600"][color="#666600"];
[color=#1C2837][size=2][color="#666600"][color="#666600"][color=#1C2837][size=2][color=#660066]Game[color=#000000] [color=#666600]=[color=#000000] [color=#660066]UTGame[color=#666600]([color=#660066]WorldInfo[color=#666600].[color=#660066]Game[color=#666600]);
[color="#000088"]

[color="#000088"][color=#000000]

the first line declares a pointer or reference variable to a UTGame class... it doesn't hold a true instance yet... the second line tells it which instance to use.

Unreal Script is more related to Java coding styles than C++. It says so, and is also provable when you actually learn Java. Now that doesn't mean you won't get confused because it is not Java, but you should be able to pick up the difference.

Wiki Description

http://en.wikipedia....ki/UnrealScript

Gears of War War Weapon.u

http://pastebin.com/hD6F35Wt

Any real questions can be asked on the Unreal Forums Here http://forums.epicga...splay.php?f=366

You will never call native unless you own a license to the Unreal Engine 3. So you don't need to worry about that until later.


Also, to help you out, you can search for unreal tournament 3 mods and mutators and look at their sources to figure out how they did something.

Like people who are successful say "Don't try to reinvent the wheel".
Failure is simply denying the truth and refusing to adapt for success. Failure is synthetic, invented by man to justify his laziness and lack of moral conduct. What truely lies within failure is neither primative or genetic. What failure is at the heart, is man's inability to rise and meet the challenge. Success is natural, only happening when man stops trying to imitate a synthetic or imaginable object. Once man starts acting outside his emotional standpoints, he will stop trying to imitate synthetic or imaginable objects called forth by the replication of his emptiness inside his mind. Man's mind is forever idle and therefore shall call forth through the primitives of such subconscious thoughts and behaviors that Success is unnatural and that failure is natural. Success is simply doing something at man's full natural abilities and power, failure is the inability to act on what man wants, dreams, wishes, invisions, or thinks himself to do. ~ RED (concluded when I was 5 years old looking at the world with wide eyes)

This topic is closed to new replies.

Advertisement