Sign in to follow this  
Stellar Developer

Defining classes for objects (like unreal uses)

Recommended Posts

From the official UnrealScript Language Reference:
Quote:
UnrealScript is bytecode based: UnrealScript code is compiled into a series of bytecodes similar to p-code or the Java bytecodes. This makes UnrealScript platform-neutral; this porting the client and server components of Unreal to other platforms, i.e. the Macintosh or Unix, is straightforward, and all versions can interoperate easily by executing the same scripts.

Unreal as a Virtual Machine: The Unreal engine can be regarded as a virtual machine for 3D gaming in the same way that the Java language and the built-in Java class hierarchy define a virtual machine for Web page scripting. The Unreal virtual machine is inherently portable (due to splitting out all platform-dependent code in separate modules) and expandable (due to the expandable class hierarchy). However, at this time, there are no plans to document the Unreal VM to the extent necessary for others to create independent but compatible implementations.

The UnrealScript compiler is two-pass: Unlike C++, UnrealScript is compiled in two distinct passes. In the first pass, variable, state and function definitions are parsed and remembered. In the second pass, the script code is compiled to byte codes. This enables complex script hierarchies with circular dependencies to be completely compiled and linked in two passes, without a separate link phase.


For an easier explanation/tutorial about how to actually use it check out
UnrealWiki: UnrealScript Lessons
Unrealscript For Dummies

Share this post


Link to post
Share on other sites
If you're looking for a scripting language that you can use in your engine, you could consider using Lua. There's an artcle/tutorial about embedding it with C/C++ here at gamedev. I've been happy with it so far.

Some alternatives would be angelscript and python.

Share this post


Link to post
Share on other sites
I'm writing a system like this for my own use, mainly as an experiment. In my system I define a 'class' which has a set of properties and methods. Using the scripting language you can extend/redefine the class, adding new properties and methods at will. My current system looks to see if you call a method or access a property, it will first check if the script has overridden the member, if so it will refer to the data there, if not it will jump to the 'native' version (although in my system the API creates members in the same was as the script does). The initial tests are going well, I just have to code a scripting language for the top of it (instead of using bytecode programs).

You can simulate the functionality using existing scripting systems. For example, in a game I was writing for the 4E4 I created a generic event system. The event would be triggered anywhere and was specified by name; to handle the event all you needed to do was create a function called [EntityName]_[EventName], eg: Alien_Update for a global handler for the alien entity class, or MyAlien_Update for a specific override for an individual entity. I've found this to be VERY powerful and I'm using it to great effect in jsInvaders.

In gmBind, my GameMonkey script binding template I allowed for exported classes to be extended. You declare your bound methods and variables (which relate to your C++ class) and then any other attributes are automatically added and stored in the scripting API. This way, you could declare your basic type in C++ and expose it to script, which could then start adding its own variables to the class - effectively a crude inheritance scheme.

It's a very fun area to work in.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this