feat: add initial People Playground mod development kit
This commit is contained in:
22
extracted_wiki_content/snippets/registering_an_item.txt
Normal file
22
extracted_wiki_content/snippets/registering_an_item.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user