NWN.Framework.Lite is an unopinionated framework for writing Neverwinter Nights code in C#.
Its intention is to provide you with minimal structure to your project while being dead simple to learn. We give you what you need to get started and then get out of your way.
- Find NWN.Framework.Lite on the Nuget feed and install it into your project.
- Create a class where your code will be written.
- Create a method like the following
// This method will be run whenever the script "sit" is run. In our example module, this happens when a player clicks a chair.
// Script names must adhere to the NWN restrictions (alphanumeric with some special characters and no longer than 16 characters)
// The method name is arbitrary and can be called whatever you want.
// Methods must be public and static so that the framework can pick them up when the module loads.
[ScriptHandler("sit")]
public static void SitOnAChair()
{
var player = NWScript.GetLastUsedBy();
var chair = NWScript.OBJECT_SELF;
AssignCommand(player, () => ActionSit(chair));
}
- Configure your NWNX server with the following environment variables. Setting up an NWNX server is outside the scope of this guide. More information can be found in the Additional Resources section of this guide.
NWNX_DOTNET_ASSEMBLY=/nwn/home/dotnet/NWN.Framework.Lite
NWNX_DOTNET_ENTRYPOINT=NWN.Framework.Lite.Internal
- Add the script "sit" to the OnUsed event of a placeable chair.
- Build the project and run the NWNX server
- Log in and click the chair. Your character should sit down.
And that's it!
[NWNX Unified] - The NWNX project which has guides on setting up a server.
[NWN Lexicon] - Contains a wealth of useful information about NWScript.
[NWN Managed] - An alternative, opinionated framework.
We welcome all contributions via Pull Request. Please read the following as they serve as our guiding principles on this project. We expect all contributions to adhere to these guidelines.
- The Lite framework is intended to be exactly as it sounds - light and unobtrusive. There are no fancy frameworks to learn. Install the package and go.
- We don't provide everything and the kitchen sink. There's some glue code, the NWScript and NWNX methods, and assorted enumerations. On the rare occasion we will also provide conversions of commonly used NWScript functions found in include files.