Upgrading your TwilioQuest NPCs for Alpha 13

June 23, 2021
Written by
Joe Nash
Twilion

Upgrading your TwilioQuest NPCs for Alpha 13

This post will walk you through updating NPCs in an TwilioQuest Alpha 12 extension to work with TwilioQuest Alpha 13. You can use this guide if you are an extension author updating your own extension, or a TwilioQuest player trying to use an extension downloaded from the internet.

TwilioQuest Extensions are a new feature that lets you create your own missions in TwilioQuest. TwilioQuest Extensions are still in alpha, and new features are being added quickly. Sometimes that means breaking changes to the API and tools. Alpha 13 of TwilioQuest 3.2 introduced 12 new ready-to-use NPCs. As a result of this change, NPCs in extensions created for Alpha 12 will have to be updated. This post will walk you through updating NPCs in an Alpha 12 extension so the extension can be played on Alpha 13.

What changed?

In Alpha 12, NPCs were added to a level by creating a point object in Tiled, and setting the type property to npc. Spritesheet and avatar were associated with the NPC with the name property. NPCs were linked to a conversation .pug file with the conversation property.

Alpha 13 introduces a number of preconfigured NPCs. These NPCs are available as objects within Tiled, via a new tileset, “TwilioQuestNPCs”. With this new tileset, it is easier for extension authors to add a variety of characters quickly, choosing from the 12 NPCs available.

The new NPC objects have type tq-npc. Conversations are linked to an NPC in the same way as before, via adding the name of a .pug file to the conversation field. Two new properties make it easier to customize NPCs. An image for the avatar can be specified with conversationAvatar, and a spritesheet can be specified with spritesheet.

Do I have to update my NPCs?

You may have to update NPCs in your extension if:

  • The extension was created for Alpha 12, or before June 17th 2021.
  • You used the extension template repository to create a repository in your own GitHub profile before June 17th 2021.
  • When you open your map in Tiled, you do not see a tileset named “TwilioQuestNPCs”

Upgrading your NPCs

The steps below will walk you through upgrading your Alpha 12 NPCs to Alpha 13, from using Alpha 13 for the first time through to a working extension. In this guide we will be upgrading one of the extensions created during a student hackathon, Hack-cade. The extension is called Extenception, and teaches players how to create a TwilioQuest extension. You can find it on GitHub.

Getting Alpha 13

Before upgrading your NPCs, you will need to use the TwilioQuest launcher to download Alpha 13. Launch TwilioQuest, and within the launcher, click “more” to select “TQ 3.2 preview”, and in the drop down, select Alpha 13. The launcher will now download Alpha 13, including the new NPC assets.

TwilioQuest Launcher with TQ 3.2 selected

When the download is complete, launch TwilioQuest, and ensure you have extensions enabled and an Extension Directory selected. The extension you want to upgrade should be in this directory. For more information on enabling extensions, see the Getting Started guide.

TwilioQuest will place a .bundled directory into the Extensions Directory you have selected. This bundle includes the base tilesets and objects for TwilioQuest, that you can use in your own extensions. As we have now downloaded Alpha 13, this bundle will include a tileset

MacOS Finder showing the .bundled folder alongside extensions

Adding the TwilioQuestNPCs tileset

Next up is to add the new TwilioQuestNPCs tileset to the maps for your extension. Open your map in Tiled by launching Tiled, selecting Open File, and finding the default.json for your level.

Extenception opened in Tiled

By default, the available tilesets are displayed in the bottom right of the Tiled editor. At the end of the tabs showing the available tilesets, you will see an arrow indicating a dropdown menu. Opening this, you will find the option for “Add external tileset”. Select this option

.

The tileset panel in Tiled

Navigate to your Extensions Directory, and find the .bundled directory. You may not be able to see the .bundled directory straight away, as the `.` prefix hides the folder. To display hidden files on MacOS you can use Cmd+Shift+., and on Windows you can enable Hidden Items under the View menu from within Explorer.

Within the .bundled directory you will see two folders, objects and tilesets. Open tilesets and find TwilioQuestNPCs.json. If you’re not able to select it, you may have to select .JSON tileset files from the dropdown within the file select, as it defaults to Tiled tileset files.

Once you’ve opened the tileset, it will be available in the tileset window within Tiled.

Replacing the NPC

With the new tileset loaded, we can replace our old point NPCs. Find any NPCs, and make a note of which conversations they were linked to. Delete those NPCs, then select the NPC you want to use from the tileset window, and place them with the Insert Tile tool. If you are unable to delete or place an NPC, check you’re on the Objects layer.

A point NPC and its properties

To link the newly placed NPCs up to your existing conversations, select the NPC and edit the conversation field to be the name of the .pug conversation file you want to use.

A new object NPC and its properties

That’s it!

Once you’ve placed the new NPCs and linked up their conversations, you should be good to go. Don’t forget to save the map before starting up TwilioQuest and taking your extension for a test drive. If you have more than one map in your extension, you may have to repeat this process for each map.

If you have questions or want to share your extension with the community, join us in the TwilioQuest Discord, or on the Twilio Community forum. Our weekly Twitch stream also regularly features TwilioQuest extension development, and Q&A with the developers.