Legacy:UnrealScript Hello World
This page is one of a series of UnrealScript Lessons.
Previous tutorials:
- You've set up your environment: Setting Up UnrealScript
Overview
This tutorial will teach you how to compile a small mutator whose sole purpose in life is to write "Hello World" into the Unreal Tournament log file (UnrealTournament.log, UT2003.log or UT2004.log).
We assume that you've never tried building anything in UnrealScript before, and you haven't got a clue where to actually start. What follows applies equally well to UT , UT2003 or UT2004.
Create the Directory Structure
In your UT directory create a directory called MutHelloWorld. MutHelloWorld is the name of our package.
In the newly created MutHelloWorld directory create another directory called Classes. (For more on this step, see Set Up Package Folders.)
You should now have the following directory structure
- {Base Directory}\MutHelloWorld
- {Base Directory}\MutHelloWorld\Classes
So far so good. Now let's write the code.
Creating the mutator
Within the {Base Directory}\MutHelloWorld\Classes directory create a new file called HelloWorld.uc.
This is just a normal text file so you can use Notepad, vi, or any other text editor application of your choice to create/edit it. The uc extension means that it's an Unreal Class file. All UnrealScript code is contained in UC Files (see that page for tips on working with them).
- Caution: Be careful to actually name your file HelloWorld.uc, not HelloWorld.uc.txt when using Notepad or another Windows text editor. By default Windows Explorer would hide the ".txt" part of the file name, so only "HelloWorld.uc" would show up along with a "text file" icon. The compiler won't find that file though and complain about it.(If you're using notepad change the "save as type" to "All files" to ensure it wont save it to a .txt file)
Place the following code within the file you just created (HelloWorld.uc)
<uscript>
class HelloWorld extends Mutator