A counter strike 2 typescript bundler that automatically compiles .vts
and .ts
typescript files into valve .vts_c
files, and bundles imported modules. Also includes type defintions for the Instance
object used to interface with CS2.
- Partial type definitions for cspointscript's
Instance
class - Auto compile
.vts
and.ts
typescript files into.vts_c
, the format needed to run in CS2 maps - Auto bundling of imports from node modules
- Auto transpiling of typescript to javascript (Needed for
.vts_c
files)
Run npx create-s2ts
at the root of your map folder. The folder should be something like /Steam/steamapps/common/Counter-Strike Global Offensive/content/csgo_addons/<map-name>
. This will setup a node project and create an example script.
npx create-s2ts
Run the install:
npm install
Once installed you can run with the start command:
npm run start
-
While running, s2ts will look for any file updates to
.vts
and.ts
files in your/scripts
folder atCounter-Strike Global Offensive/content/csgo_addons/<map-name>/scripts
and automatically compile then save them toCounter-Strike Global Offensive/game/csgo_addons/<map-name>/scripts
. -
In hammer, you need to add a point_script entity that references your script. It should have a
targetname
key to allow other entities to trigger public methods in the script. It should also have ascript
key that references your script file.
Warning
Your script file path needs to have the .vts
extension in hammer, even if it is a .ts
file.
-
You can find an example typescript script at
/scripts/example.ts
. Update and save this script while s2ts is running, and the script will be compiled. Use the console to restart the game withmp_restartgame 1
for the script update to take effect. -
Functions declared via
Instance.PublicMethod()
can be called from hammer's input/output system by triggering an output to the point_script entity with the name of the public function in the "Via this input" field.
This repo for the structure of a vts_c file (Big thankyou)