UnrealScript Tips

by Dizzy

Including UScript in a Map

If you want to include UnrealScript in a map, there are several ways to do it.

External Scripts

The easiest way to include scripts, but you will have to include external .u files when releasing your map and players will have to download these. Your map won't work without them.

Simply open the Editor's Actor Browser and choose File -> Open Package.

The script will then appear in the editor's Actor Browser underneath its parent class (for example, if it's a pickup item, it will appear under Actor -> Inventory -> Pickup). This will depend on the script itself and how it's written.

Importing Scripts into MyLevel

This is the cleanest way of including scripts in a map, because it removes the need for players to download external .u files when loading your map.

If you want to import an existing (compiled) .u file, you must place it in your UT/System folder and then use the following command in the Unreal Editor console (the input box at the bottom of the editor):

obj load file=..\System\WhateverScript.u package=MyLevel.WhateverScript

The script will then appear in the editor's Actor Browser underneath its parent class (for example, if it's a pickup item, it will appear under Actor -> Inventory -> Pickup). This will depend on the script itself and how it's written.

Creating New Scripts in MyLevel/UnrealEd

If you want to include a really simple script in a map which you're developing on-the-fly, you might find it easier to create and compile the script straight in UEd itself.

Open the Actor Browser and click on your desired parent class (e.g. Pickup, Trigger, etc. or just Actor). Then click the New Script icon, and insert "MyLevel" as the package name. You can then edit and compile your script by choosing Tools -> Compile Changed.

You will then see your script appear in the Actor browser tree, again under its parent class. For the script to have an effect on gameplay, you'll have to include it in the map (once) as a "physical" (but invisible) actor.