Skip to content

Getting started with ts2

ts2 is the language you write Rift interfaces in: shop windows, inventory grids, quest logs, health bars. It’s a small, statically typed language with markup built in. The build turns your code into interfaces the game client loads.

src/shop.ts2
import { createRef, sessionState, useInventory, useState } from 'ts2';
import { Colors, Fonts, Icons, Inventories, Items } from './refs';
const CoinPurse = (): Component => {
const inventory = useInventory(Inventories.INVENTORY);
const coins = inventory.total(Items.COINS);
return (
<layer x={0} y="bottom" w="fill" h={24}>
<sprite x={2} y="center" w={20} h={20} sprite={Icons.COINS} />
<text x={26} y="center" w={120} h={16} text={`${coins} gp`} font={Fonts.BOLD}
valign="middle" shadow color={Colors.AMBER} />
</layer>
);
};

Reference has a page per element and per hook, and the complete lists of props, types, collections and error codes. Rules of ts2 lists what the compiler refuses. Extra topics explain how updates reach the screen.