how to create a custom item data template for foundry vtt

5- Creating A New System For Foundry VTT: The Item Data Template

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

Creating An Item Data Template For Foundry VTT

Open up your favorite JavaScript editor and create a blank template.json file or open an existing one.

We are going to build a very basic Item template, then we are going to make sure that Foundry VTT creates the Item 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 Item to hold information about an inventory object.

The Item subtype will be "weapon" and it will have a "damage" attribute that holds how many points of damage it does.

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

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

{
"Item": {
    "types":["weapon"],
        "weapon":{
            "damage": 5
        }
}
}

 

Test It!

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

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

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

test character sheet

These two fields are built into the standard default Item Sheet and don't need to be defined, although you can override them.

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

 

Troubleshooting

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

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

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

How can I double-check an Item data structure was created without an item sheet set up?
You can also create and directly view an Item object by running a piece of code in the JavaScript console on your browser or in the Foundry VTT application.

Just press F12 to open the Developer Tools in Foundry VTT or your web browser.  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:

Item.create({name: "Test Weapon", type: "weapon"}).then(item => {console.log(item.data);})

You should get something like the following:

Foundry VTT | Created Item with id TxEe8nohkGel8fF0
{name: "Test Weapon", permission: {…}, type: "weapon", data: {…}, sort: 100001, …}
name: "Test Weapon"
permission: {default: 0, yiJrun7Whq554OvL: 3}
type: "weapon"
data: {damage: 5}
sort: 100001
flags:
__proto__: Object
effects: []
_id: "TxEe8nohkGel8fF0"
img: "icons/svg/mystery-man.svg"
__proto__: Object

 

We can see our Item has been created, a name and picture applied, plus we can see the data we added for the damage attribute has been set to 5.

Success!

 

What Next?

Next, we'll create a custom Item Sheet.

Check out Part 6- Creating A New System For Foundry VTT: Creating A Custom Item Sheet

 

Your Turn: What Do You Do?

Try to duplicate my work, then expand upon it. 

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

Open the Console and create an Item 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   Email

Add A Comment


Related Articles