Templates: Difference between revisions

From Citizens Wiki

Line 23: Line 23:
}}
}}


Now, we can create an NPC with our desired template using <pre>/npc create Helpful Guard --templates awesometemplates:towninfo</pre>.
Now, we can create an NPC with our desired template using <pre>/npc create Helpful Guard --templates awesometemplates:towninfo</pre>


== Other commands ==
== Other commands ==

Revision as of 18:16, 2 January 2025

Templates are a simple way to share NPC configuration across NPCs and servers.

Layout

Templates are stored in the plugins/Citizens/templates folder.

Each template consists of a namespace or a folder to group related templates together and a bunch of template files.

Example

Let's build a quick example.

Make a folder called plugins/Citizens/templates/awesometemplates.

Inside this, create a .yml file. This can have any file name, and the file name is just for your grouping purposes. The first one is info.yml.

Inside info.yml, put the following template:


Code:
towninfo:
    commands:
        on_spawn:
            - say Hello!

Now, we can create an NPC with our desired template using

/npc create Helpful Guard --templates awesometemplates:towninfo

Other commands

You can generate a copy of another NPC's save data directly using for example /template generate awesometemplates:towninfocopy. This will save it into a file called towninfocopy.yml.

You can apply a template to an existing NPC by using /template apply awesometemplates:towninfo.