Skip to content

Commit

Permalink
Create new project with ts example file instead of vts for simpler id…
Browse files Browse the repository at this point in the history
…e typescript detection
  • Loading branch information
Peterclark1996 committed Aug 12, 2024
1 parent 2c214e2 commit 9d74e37
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Source 2 TypeScript
A counter strike 2 typescript bundler that automatically compiles `.vts` and `.ts` typescript files into valve `.vts_c` files, and also bundles imported modules. Also includes type defintions for the `Instance` object used to interface with CS2.
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.

## Features
- Partial type definitions for cspointscript's `Instance` class
Expand All @@ -26,12 +26,15 @@ npm run start

1. While running, s2ts will look for any file updates to `.vts` and `.ts` files in your `/scripts` folder at `Counter-Strike Global Offensive/content/csgo_addons/<map-name>/scripts` and automatically compile then save them to `Counter-Strike Global Offensive/game/csgo_addons/<map-name>/scripts`.

2. 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 a `script` key that references your script file.
![point_script_example](point_script_example.png "Example of a point_script to load an example.vts script")
2. 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 a `script` 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.
3. You can find an example typescript script at `/scripts/example.vts`. Update and save this script while s2ts is running, and the script will be compiled. Use the console to restart the game with `mp_restartgame 1` for the script update to take effect.
![point_script_example](point_script_example.png "Example of a point_script to load an example.ts script")

4. Functions declared via `Instance.PublicMethod()` can be called from the input/outputs system by calling the point_script entity with the name of the public function in the "Via this input" field.
3. 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 with `mp_restartgame 1` for the script update to take effect.

4. 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.
![output_public_fun_example](output_public_fun_example.png "Example of an output triggering a public function on a point_script")

## Reference
Expand Down
2 changes: 1 addition & 1 deletion packages/create-s2ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-s2ts",
"version": "0.3.0",
"version": "0.3.1",
"description": "A tool to scaffold a s2ts project",
"main": "dist/index.js",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-s2ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Instance.PublicMethod("PublicFunc", () => {
Instance.Msg("Hello World!") // Runs when the script receives an input of "PublicFunc"
})`

writeFileSync(path.join(rootPath, "scripts/example.vts"), exampleScript)
writeFileSync(path.join(rootPath, "scripts/example.ts"), exampleScript)

console.log("Successfully created s2ts project")
}
Expand Down
2 changes: 1 addition & 1 deletion packages/s2ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s2ts",
"version": "0.3.0",
"version": "0.3.1",
"description": "A tool to automatically compile counter-strike TS files (.vts files)",
"main": "dist/index.js",
"bin": {
Expand Down

0 comments on commit 9d74e37

Please sign in to comment.