how to create a custom actor data template for foundry vtt

4- Creating A New System For Foundry VTT: The Actor Data Template

Hits: 489

Creating a new Actor for your custom Foundry VTT system can get really complicated. Let's start from a simple building block and create our own custom Actor Data Template.

Creating An Actor Data Template For Foundry VTT

Open up your favorite JavaScript editor and create a blank template.json file.

We are going to make a very basic Actor template, then we are going to make sure that Foundry VTT creates the Actor as we expected.

This article builds upon information contained in the previous article: Creating A New System For Foundry VTT: The Data Template

 

Making It FutureSpace

Let's start out with something easy. 

In our example, we are going to create a new Actor to hold information about a player.

The Actor subtype will be "PC" and it will only hold one attribute: health.  Health will be a "resource" key so that we can link a token's status bar in the future.

For our FutureSpace example, let's do the following:

{userData}/Data/systems/futurespace/template.json

{
    "Actor": {
        "types": ["PC"],
            "PC": {
                "health": {
                    "value": 21,
                    "max": 21
                }
            }
    }
}

 

Test It!

Let's make sure everything we have done so far works properly.

Next, let's check that we can create a new player.

Go to the Actors Directory tab and Create Actor.  You should have a blank new character sheet that only shows the default image and the character's name.

test character sheet

These two fields are built into the standard default Character Sheet.

If you can't make a new character, go back and check your templates.json file for typos.

 

Troubleshooting

Why don't we see the health?
The default character sheet doesn't have a handler for the custom field named "health".  We will add that in a future article on making custom character sheets.

Why didn't we get a choice of what kind of actor to make?
When there is only one Actor Type listed, you don't get a drop-down menu.  You only get a drop-down if there is more than one Actor Type defined.

How can I verify an Actor has been created?
You know you've created an Actor because you now have an Actor card in your Actor Directory.

How can I double-check an Actor data structure was created without a character sheet set up?
You can also create and directly view an Actor object by running a piece of code in the console.

Just press F12 to open the Developer Tools in Foundry VTT.  This will give you access to various developer tools, including the CSS inspector - but for now, we want the Console tab. 

Once on the Console screen, enter the following code:

Actor.create({name: "Test Actor", type: "PC"}).then(actor => {console.log(actor.data);})

You should get something like the following:

Foundry VTT | Created Actor with id lQ4WJAPhVxgHahI3
{name: "Test Actor", permission: {…}, type: "PC", data: {…}, sort: 100001, …}
name: "Test Actor"
permission: {default: 0, yiJrun7Whq554OvL: 3}
type: "PC"
data:
health: {value: 21, max: 21}
__proto__: Object
sort: 100001
flags: {}
token: {flags: {…}, name: "Test Actor", displayName: 0, img: "icons/svg/mystery-man.svg", tint: null, …}
items: []
effects: []
_id: "lQ4WJAPhVxgHahI3"
img: "icons/svg/mystery-man.svg"
__proto__: Object

 

We can see our actor has been created, a name and portrait applied, plus we can see the data we added for the health attribute.

Success!

 

What Next?

Next, we will look at the Item Template.

Check out: Part 5- Creating A New System For Foundry VTT: The Item Data Template.

 

Your Turn: What Do You Do?

Try to duplicate my work, then expand upon it. 

Create another Actor Type and make sure it gets listed on the Create Actor window. 

Open the Console and create an Actor object by hand, inspect its properties to be sure it was made correctly.

Tell me about it in the Comments Section.  I'm interested in what you have to say about creating your own Foundry VTT Data Template.


 

E-mail Notification Opt-in

Do you want to receive email notifications when we add new game design content?

Sign up on our private mailing list.

YES! Notify me of new game design posts!

Sign up for tips and tricks to make your own RPG.

We don't share your info or spam you. Unsubscribe any time.

Print

Related Articles