Modding

From NS2 community wiki
Revision as of 06:31, 6 March 2012 by PsiWarp (Talk | contribs)

Jump to: navigation, search

Contents

Introduction

A guide to importing your own custom textures can be found here.

Where to find your Natural Selection 2 directory

The directory can be found at "C:\Program Files\Steam\steamapps\common\Natural Selection 2" if steam was installed in the default location. Whenever you see NSROOT on this page it means this directory.

Launching your mod

This instruction will walk you through launching a mod. For the purpose of this demonstration, we will use an imaginary mod called "tsa".

  • Move the Mod folder tsa into your "....\steam\steamapps\common\natural selection 2\" folder.
  • Right click on ns2.exe and click on send to desktop (create shortcut).
  • Right click the shortcut and select properties.
  • Find the line called target and after the "....\Steam\steamapps\common\natural selection 2\NS2.exe" add: -game tsa.
  • On my computer the target line reads - "F:\Games\Steam\steamapps\common\natural selection 2\NS2.exe" -game tsa
  • Click the general tab of the properties window.
  • Change the name from "shortcut to ns2" to "tsa".
  • Click OK.
  • Double Click the tsa desktop icon to launch the mod.

The -game commandline argument causes the game engine to search for game files at the address provided. Using -game tsa, would cause the engine to search for the mod folder in the NSROOT folder. You can also specify a full path if you have decided to put your mod files in a different folder i.e. -game "c:\mystuff\tsa". When ever you see MODDIR on this page it means the directory set by the -game commandline.

Game_setup.xml

The optional game_setup.xml file (in a mods directory) controls what the first lua file the Client and Server lua VMs will load, also what the title of the ns2 window will be. If your mod doesn't have one in its root directory, the engine will default to loading "NSROOT\ns2\game_setup.xml"

The default game_setup.xml looks like this:

<game>
 <name>ns2</name>
 <description>Natural Selection 2</description>
 <client>lua/Client.lua</client>
 <server>lua/Server.lua</server>
</game>

The description node controls what title of ns2 window will be. If client and server nodes are empty in your game_setup.xml file, the game will default to loading "MODDIR\lua\Client.lua" for the client vm and "MODDIR\lua\Server.lua" for the server VM. If either of those don't exist, the game defaults to loading the normal ns2 entry point lua files "NSROOT\ns2\Client.lua" for the Client VM and "NSROOT\ns2\Server.lua" for the server VM.

Key Input Example - Hello World to Console

function SendKeyEvent(key, down)
if key == InputKey.Q and down then
Shared.Message('Hello World')
end
end
Event.Hook("SendKeyEvent", OnSendKeyEvent)

Other tips

If you want to write something to the console use Shared.Message("some message")

Personal tools