UE2 - UT2kX New: UnrealScript questions

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Explosix

New Member
Aug 29, 2011
3
0
0
Hello.

I am rather new to Unrealscript. Actually I haven't programmed in it yet, but I have a few questions regarding its structure and features. I am a literate C/C++ programmer though, so the syntax looks familiar, and I can understand most of the language. Although there are a few things I'd like to ask about the internal workings of unreal engine.

I'll begin with this:

Let's say I create a new class in UnrealEd - it's a subclass of the Trigger class. I name it "UltraWind" and it resides in my own package "CoolTriggers". Now what would happen, if there was another class of the same name already present and loaded? Obviously we have a name conflict, but is this legal in unrealscript? i.e. the first class is named "UltraWind" and is a subclass of the "Trigger" class, and belongs to package "CoolTriggers". The second one is also named "UltraWind", but instead it is a subclass of the "Keypoint" class and resides in the package "SpeedPath". Note that both packages are custom made, and both have to be loaded in a level. How does this scenario play out?



Regards
 

Explosix

New Member
Aug 29, 2011
3
0
0
Hey Rachel, nice to see you again!
I remember you from the old days when I still played UT2004 - The OMFG gun (lol) and DM-Reconstruct (one of my fav maps).

Anyway, I am not using any particular version of unreal engine, but I'll stick to UT2004 because I'm most familiar with that. The reason I'm asking is because I'd like to sort out some details for a scripting engine that I'm working on. It has a number of features that were directly inspired by Unrealscript. I'd like to learn how the unreal engine handles this kind of stuff.

You see, in relation to my first question it is the kind of stuff that is unavoidable when it comes to allowing users to add their own classes. What are the chances that two users will eventually make a class with the same name - unaware of each other? Then how does one use both of those classes in a level editor? How do you spawn each class in game? I assume it's okay to specify the full path to class i.e. PackageName.ClassName. What happens when you don't specify a full name?

...
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
If UT2004 is anything like UT, the packages don't make a difference and the game will fetch only of the classes with the corresponding name. This obviously leads to errors depending on whether the class is the correct one or not. In a language like Java this wouldn't be the case as the package name is taken into account. Also, spawning of custom content is down using dynamic loading. You also should realize that spawning isn't the equivalent of instantiation. What probably happens is a two-step process: 1) Instantiate the class, 2) Register the class as an Actor so it interacts with the virtual world.
 
Last edited:

Explosix

New Member
Aug 29, 2011
3
0
0
I see. So there's an error generated, if the engine attempts to load a class with the same name as an existing one regardless of the package it resides in.

Okay, another question. I'm not actually sure whether this applies to UT2004, but I read on some tutorials that the unreal engine uses so called "probe functions". These are functions that can be deactivated and reactivated by using the Disable() and Enable() calls i.e. Disable( 'Tick' );

Quite an interesting feature to be honest. But... How can someone differ between a probe function and a normal function? Is the function declaration different? What exactly does disabling such function do - does it only prevent the engine from calling these functions when an event occurs? What happens when a script class calls a disabled function on another object - does it get executed?


Regards...
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Disable() also applies to calls from UnrealScript as far as I can tell.

Classes with the same name in different packages do work, but in many places you are not allowed to fully qualify the class name (typecasting and declarations), so you don't know which of the classes with the same name the compiler will actually use. Once it compiled the way you want, the engine won't have any problems with that anymore, as bytecode references classes directly, not by simple name. Also, dynamically loading classes is done with the fully qualified name, so no problems there either.
 

KingJackaL

New Member
Sep 11, 2005
3
0
0
Class conflicts - we normally get around this by namespacing our class names.

So in your case I'd use the class name 'CT_UltraWind'. OK, so there's a chance somebody else has a 'Cromulent Tangents' project with an 'UltraWind' class, but it's unlikely.


I don't know for sure, but I'd guess a probe function is just setting some var to on/off in a central table. And the native code that runs 'Tick' etc just checks that table and if that table has a 'turn off' value, returns straight away.