Skip to content

Quick Start

Simie edited this page Nov 20, 2012 · 1 revision

This page will give you a quick introduction into working with Papyrus.

The First Plugin

For this first example we're skipping the creation of a Type Module. We'll get to that soon.

When creating a record database, the MutableRecordDatabase class is used. When using Papyrus in a game you would usually use the read-only RecordDatabase instead.

// Use the PluginUtilities helper class to create an empty plugin in the current directory
var pluginHeader = Papyrus.PluginUtilities.CreateNewPlugin("NewPlugin", Environment.CurrentDirectory);
			
// Create a mutable database with only the new plugin as the active file
var database = new Papyrus.Design.MutableRecordDatabase(new string[] {}, pluginHeader.SourceFile);

// Create a simple graphic asset
var assetEntry = database.NewRecord<RecordTypes.GraphicAsset>();

// Assign any values to properties on the object

assetEntry.AssetPath = @"C:\SomeSamplePath\ToYour\Asset.png";
assetEntry.Owner = "Stompy Robot";

// Save the record to the database
database.SaveRecord(assetEntry);

// Save the active plugin
database.SaveActivePlugin();

This simply creates a new plugin using the PluginUtilities helper class and adds a single GraphicAsset object to it. Let's take a look at the GraphicAsset type:

public class GraphicAsset : SampleRootRecord
{

	[Papyrus.RecordProperty(1)]
	public string AssetPath { get; set; }
	
	[Papyrus.RecordProperty(2)]
	public string Owner { get; set; }

}

Record types are simply C# classes containing properties tagged with attributes. This is a slightly simplified record type, usually some checks for ReadOnly being true are used to prevent unintentional modifications to records while the game is running. There is also ViewModel functionality provided for editor support.

The Type Model

Clone this wiki locally