Always snap to grid

Difference between revisions of "How to Make an Inventory"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (page needs better wikification)
(Cleaned up, this tutorial might need to be rewriten to be compatible with all unreal engine generations.)
Line 1: Line 1:
 
{{wikify}}
 
{{wikify}}
This is a tutorial for Unreal Tournament 3.  
+
This is a tutorial for [[Unreal Tournament 3]] written by '''Izanagi'''.  
 
+
I will show you a really easy way of creating a customisable inventory for your mods. This tutorial also uses a static mesh component that you can either create yourself or use one already prepared earlier.
+
 
+
I am not going to go into really in-depth information about it all, if you need more info check out the rest of wiki.beyondUnreal.com
+
 
+
  
 +
This tutorial will show you a really easy way of creating a customizable inventory for your mods. This tutorial also uses a static mesh component that you can either create yourself or use one already prepared earlier.
  
 +
This tutorial will go into really in-depth information about it all, if you need more info check out the rest of {{SERVERNAME}}.
  
 
== The Basics and Downloads ==
 
== The Basics and Downloads ==
 
 
This tutorial uses basic coding, so you will (if you haven't already) download yourself a copy of [http://www.contexteditor.org/ ConTEXT Editor], or [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++]. Both programs are for Windows, but I'm sure there would be similar ones for other operating systems.
 
This tutorial uses basic coding, so you will (if you haven't already) download yourself a copy of [http://www.contexteditor.org/ ConTEXT Editor], or [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++]. Both programs are for Windows, but I'm sure there would be similar ones for other operating systems.
  
 
I use ConText because the syntax [http://www.xsmod.com/xyx/ut/xs/rants/ut3scriptsetup/UScript3.chl highlighter] is available making coding easier. You may need to right-click the link and choose '''Save Target As'''... and place it in the '''Program Files\ConTEXT\Highlighters''' folder to enable syntax highlighting.
 
I use ConText because the syntax [http://www.xsmod.com/xyx/ut/xs/rants/ut3scriptsetup/UScript3.chl highlighter] is available making coding easier. You may need to right-click the link and choose '''Save Target As'''... and place it in the '''Program Files\ConTEXT\Highlighters''' folder to enable syntax highlighting.
 
 
  
 
You may also need to download the [http://www.moddb.com/members/21982/ambershee/downloads/9999/ut3-scripts-current-11-updated source code] files. You will have to unzip and export them into '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src'''   
 
You may also need to download the [http://www.moddb.com/members/21982/ambershee/downloads/9999/ut3-scripts-current-11-updated source code] files. You will have to unzip and export them into '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src'''   
  
 
If the folder doesn't exist, then you can create it.
 
If the folder doesn't exist, then you can create it.
 
  
 
== Setting up the Scripts ==
 
== Setting up the Scripts ==
 
 
 
In the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src''' folder create a new folder and name it something along the lines of "NewInventory". Then open that folder and create a new one called "Classes". This is where you should save all of your new code.
 
In the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src''' folder create a new folder and name it something along the lines of "NewInventory". Then open that folder and create a new one called "Classes". This is where you should save all of your new code.
  
 
+
You have to tell the game about your new inventory, so UT3 has the ability to recognize your unpublished scripts.  
You have to tell the game about your new inventory, so UT3 has the ability to recognise your unpublished scripts.  
+
  
 
Open '''My Documents\My Games\Unreal Tournament 3\UTGame\Config\UTEditor.ini''' in ConTEXT and search (Control+F) for [ModPackages].  
 
Open '''My Documents\My Games\Unreal Tournament 3\UTGame\Config\UTEditor.ini''' in ConTEXT and search (Control+F) for [ModPackages].  
 
Underneath the line that reads '''ModOutputDir=..\UTGame\Unpublished\CookedPC\Script''', add the following line:
 
Underneath the line that reads '''ModOutputDir=..\UTGame\Unpublished\CookedPC\Script''', add the following line:
  
 
+
<code>ModPackages=NewInventory</code>
<uscript>
+
      ModPackages=NewInventory
+
</uscript>
+
 
+
 
+
 
+
 
+
  
 
== Setting up the Compiler ==
 
== Setting up the Compiler ==
 
 
 
On your desktop you should have an '''Unreal Tournament 3''' icon displayed.
 
On your desktop you should have an '''Unreal Tournament 3''' icon displayed.
 
Copy the icon and paste it in the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes''' folder
 
Copy the icon and paste it in the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes''' folder
Line 52: Line 33:
  
 
I keep my compiler in with the code I write because it is easier to find.
 
I keep my compiler in with the code I write because it is easier to find.
 
 
  
 
Now to begin!
 
Now to begin!
 
 
 
 
  
 
== Inventory Creation ==
 
== Inventory Creation ==
 
 
 
 
Create a new ConText file:
 
Create a new ConText file:
  
 
<uscript>class NewItem extends UTInventory;
 
<uscript>class NewItem extends UTInventory;
 +
 
defaultproperties
 
defaultproperties
 
{
 
{
Line 81: Line 54:
 
}</uscript>
 
}</uscript>
  
 
+
Save the file as NewItem.uc, now going through the important parts of the code:
 
+
Save the file as NewItem.uc  
+
 
+
 
+
 
+
 
+
Now going through the important parts of the code:
+
 
+
  
 
<uscript>class NewItem extends...</uscript>
 
<uscript>class NewItem extends...</uscript>
The '''NewItem''' name can be named to anything you want, just make sure that the filename has the same name.
+
The '''NewItem''' name can be named to anything you want, just make sure that the filename equal to the class name.
 
+
 
+
  
 
<uscript>StaticMesh=StaticMesh'folder.folder.NameOfMesh'</uscript>
 
<uscript>StaticMesh=StaticMesh'folder.folder.NameOfMesh'</uscript>
 
Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar 3D program, or you can use one from UT3.
 
Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar 3D program, or you can use one from UT3.
 
 
  
 
<uscript>scale=1</uscript>
 
<uscript>scale=1</uscript>
 
Sizes the mesh up or down, according to your tastes.
 
Sizes the mesh up or down, according to your tastes.
 
 
  
 
<uscript>Rotation=(pitch=16384, yaw=0, roll=0)</uscript>
 
<uscript>Rotation=(pitch=16384, yaw=0, roll=0)</uscript>
 
Rotates the mesh. The 16384 is a 90 degree rotation.
 
Rotates the mesh. The 16384 is a 90 degree rotation.
 
 
 
 
 
 
 
 
 
  
 
Now create a new ConText document:
 
Now create a new ConText document:
  
 
<uscript>class PickupItem_NewItem extends UTPickupInventory;
 
<uscript>class PickupItem_NewItem extends UTPickupInventory;
 +
 
defaultproperties
 
defaultproperties
 
{
 
{
Line 133: Line 84:
 
}</uscript>
 
}</uscript>
  
 
+
Save this one as PickupItem_NewItem.uc, this name is what will appear in the list in the UT3 editor. Remembering that you name the '''NewItem''' the same as in the previous code so that it reads properly. Now to go through the important parts of the code once again.
 
+
 
+
Save this one as PickupItem_NewItem.uc
+
 
+
This name is what will appear in the list in the UT3 editor.
+
 
+
Remembering that you name the '''NewItem''' the same as in the previous code so that it reads properly.
+
 
+
 
+
 
+
 
+
Now to go through the important parts of the code once again.
+
 
+
 
+
  
 
<uscript>...extends UTPickupInventory;</uscript>
 
<uscript>...extends UTPickupInventory;</uscript>
 
This tells UT3 that you are extending the PickupInventory class so that the item will be a pickup when placed in the game.
 
This tells UT3 that you are extending the PickupInventory class so that the item will be a pickup when placed in the game.
 
 
 
  
 
<uscript>InventoryType=class'NewItem'</uscript>
 
<uscript>InventoryType=class'NewItem'</uscript>
 
This tells the PickupInventory that there is a new item that can be selected.
 
This tells the PickupInventory that there is a new item that can be selected.
 
 
 
 
  
 
<uscript>  StaticMesh=StaticMesh'folder.folder.NameOfMesh'
 
<uscript>  StaticMesh=StaticMesh'folder.folder.NameOfMesh'
Line 167: Line 97:
 
</uscript>
 
</uscript>
 
If you change the size or the rotation of the static mesh in one piece of code you must change the other as well.
 
If you change the size or the rotation of the static mesh in one piece of code you must change the other as well.
 
  
 
Congratulations!
 
Congratulations!
 
  
 
Now to compile the code.
 
Now to compile the code.
  
 
== Compiling the Code ==
 
== Compiling the Code ==
 
 
 
 
Double-click on the compiler icon in the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes\''' folder and watch it compile.
 
Double-click on the compiler icon in the '''C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes\''' folder and watch it compile.
  
 
+
There should not be any errors, if there are, double-check the syntax.  
There should not be any errors, if there are, double-check the syntaxes.  
+
 
+
  
 
Now to open the Editor...
 
Now to open the Editor...
 
 
  
 
Make sure that you have saved both your files as '''.uc'''.
 
Make sure that you have saved both your files as '''.uc'''.
If you get the error '''Unexpected 'i'''', copy the code into a new file and re-save it. This just means that the UT3 compiler doesn't recognise the format that the file was saved under, even if it was saved as a .uc.
+
If you get the error '''Unexpected 'i'''', copy the code into a new file and re-save it. This just means that the UT3 compiler doesn't recognize the format that the file was saved under, even if it was saved as a .uc.
 
+
 
+
 
+
 
+
  
 
== In the Editor ==
 
== In the Editor ==
 
 
 
In the Generic Browser click on the '''Actor Classes''' tab.
 
In the Generic Browser click on the '''Actor Classes''' tab.
 
 
Go to '''Navigation Point''' then '''PickupFactory'''  
 
Go to '''Navigation Point''' then '''PickupFactory'''  
 
 
Open the '''UTPickupFactory''' and your item should be there in the list of pickups!!
 
Open the '''UTPickupFactory''' and your item should be there in the list of pickups!!
 
 
Select it then right click in the Perspective View and select '''Add PickupItem_NewItem Here'''
 
Select it then right click in the Perspective View and select '''Add PickupItem_NewItem Here'''
 
+
And that is it!.
And that is it!  
+
 
+
 
+
 
+
 
+
Good luck!
+
 
+
 
+
Izanagi
+
  
 
[[Category:Programming tutorials (UT3)]]
 
[[Category:Programming tutorials (UT3)]]

Revision as of 10:21, 17 June 2010

This is a tutorial for Unreal Tournament 3 written by Izanagi.

This tutorial will show you a really easy way of creating a customizable inventory for your mods. This tutorial also uses a static mesh component that you can either create yourself or use one already prepared earlier.

This tutorial will go into really in-depth information about it all, if you need more info check out the rest of wiki.beyondunreal.com.

The Basics and Downloads

This tutorial uses basic coding, so you will (if you haven't already) download yourself a copy of ConTEXT Editor, or Notepad++. Both programs are for Windows, but I'm sure there would be similar ones for other operating systems.

I use ConText because the syntax highlighter is available making coding easier. You may need to right-click the link and choose Save Target As... and place it in the Program Files\ConTEXT\Highlighters folder to enable syntax highlighting.

You may also need to download the source code files. You will have to unzip and export them into C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src

If the folder doesn't exist, then you can create it.

Setting up the Scripts

In the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src folder create a new folder and name it something along the lines of "NewInventory". Then open that folder and create a new one called "Classes". This is where you should save all of your new code.

You have to tell the game about your new inventory, so UT3 has the ability to recognize your unpublished scripts.

Open My Documents\My Games\Unreal Tournament 3\UTGame\Config\UTEditor.ini in ConTEXT and search (Control+F) for [ModPackages]. Underneath the line that reads ModOutputDir=..\UTGame\Unpublished\CookedPC\Script, add the following line:

ModPackages=NewInventory

Setting up the Compiler

On your desktop you should have an Unreal Tournament 3 icon displayed. Copy the icon and paste it in the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes folder Right-click on it and open the Properties. In the Target line, after "C:/.../Unreal3/Binaries/UT3.exe" type make This creates the compiler.

I keep my compiler in with the code I write because it is easier to find.

Now to begin!

Inventory Creation

Create a new ConText file:

class NewItem extends UTInventory;
 
defaultproperties
{
  Begin object Class=StaticMeshComponent Name=StaticMeshComponent1
  StaticMesh=StaticMesh'folder.folder.NameofMesh'
  scale=1
  Rotation=(pitch=16384, yaw=0, roll=0)
 
  End Object
 
  DroppedPickupMesh=StaticMeshComponent1
  PickupFactoryMesh=StaticMeshComponent1
}

Save the file as NewItem.uc, now going through the important parts of the code:

class NewItem extends...

The NewItem name can be named to anything you want, just make sure that the filename equal to the class name.

StaticMesh=StaticMesh'folder.folder.NameOfMesh'

Links the prepared static mesh to the code. The static mesh can be exported directly from 3DsMax or a similar 3D program, or you can use one from UT3.

scale=1

Sizes the mesh up or down, according to your tastes.

Rotation=(pitch=16384, yaw=0, roll=0)

Rotates the mesh. The 16384 is a 90 degree rotation.

Now create a new ConText document:

class PickupItem_NewItem extends UTPickupInventory;
 
defaultproperties
{
  InventoryType=class'NewItem'
 
  Begin object Name=BaseMeshComp
  StaticMesh=StaticMesh'folder.folder.NameofMesh'
  scale=1
  Rotation=(pitch=16384, yaw=0, roll=0)
 
  End Object
}

Save this one as PickupItem_NewItem.uc, this name is what will appear in the list in the UT3 editor. Remembering that you name the NewItem the same as in the previous code so that it reads properly. Now to go through the important parts of the code once again.

...extends UTPickupInventory;

This tells UT3 that you are extending the PickupInventory class so that the item will be a pickup when placed in the game.

InventoryType=class'NewItem'

This tells the PickupInventory that there is a new item that can be selected.

  StaticMesh=StaticMesh'folder.folder.NameOfMesh'
           scale=1
           Rotation=(pitch=16384, yaw=0, roll=0)

If you change the size or the rotation of the static mesh in one piece of code you must change the other as well.

Congratulations!

Now to compile the code.

Compiling the Code

Double-click on the compiler icon in the C:\Documents and Settings\My Documents\My Games\Unreal Tournament 3\UTGame\Src\NewInventory\Classes\ folder and watch it compile.

There should not be any errors, if there are, double-check the syntax.

Now to open the Editor...

Make sure that you have saved both your files as .uc. If you get the error Unexpected 'i', copy the code into a new file and re-save it. This just means that the UT3 compiler doesn't recognize the format that the file was saved under, even if it was saved as a .uc.

In the Editor

In the Generic Browser click on the Actor Classes tab. Go to Navigation Point then PickupFactory Open the UTPickupFactory and your item should be there in the list of pickups!! Select it then right click in the Perspective View and select Add PickupItem_NewItem Here And that is it!.