22 lines
1.1 KiB
Plaintext
22 lines
1.1 KiB
Plaintext
URL: https://wiki.studiominus.nl/snippets/registerItem.html
|
|
Title: People Playground Modding - Registering an item
|
|
==================================================
|
|
|
|
Registering an item
|
|
This code snippet shows a simple template of a ModAPI.Register call.
|
|
// register item to the mod api
|
|
ModAPI.Register(
|
|
new Modification()
|
|
{
|
|
OriginalItem = ModAPI.FindSpawnable("Knife"), //item to derive from
|
|
NameOverride = "Dagger -MoreMelee", //new item name with a suffix to assure it is globally unique
|
|
DescriptionOverride = "It is a dagger.", //new item description
|
|
CategoryOverride = ModAPI.FindCategory("Melee"), //new item category
|
|
ThumbnailOverride = ModAPI.LoadSprite("daggerView.png"), //new item thumbnail (relative path)
|
|
AfterSpawn = (Instance) => //all code in the AfterSpawn delegate will be executed when the item is spawned
|
|
{
|
|
//get the SpriteRenderer and replace its sprite with a custom one
|
|
Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("dagger.png");
|
|
}
|
|
}
|
|
); |