An Introduction to Squirrel: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== [https://sigwiki.potato.tf/index.php?title=An_Introduction_to_Squirrel Overview] == | == [https://sigwiki.potato.tf/index.php?title=An_Introduction_to_Squirrel Overview] == | ||
This is a relatively brief beginner's guide to the Squirrel language (v3.2) aimed at people with no programming experience | This is a relatively brief beginner's guide to the Squirrel language (v3.2) aimed at people with little to no programming experience. While this guide is intended to be used by people wanting to learn VScript for TF2, it doesn't cover anything regarding how to use VScript itself. | ||
If you already have experience with C-like languages or programming in general I would recommend you visit the [http://squirrel-lang.org/squirreldoc/reference/index.html Squirrel Reference Manual] for a more expedient learning experience | If you already have experience with C-like languages or programming in general I would recommend you visit the [http://squirrel-lang.org/squirreldoc/reference/index.html Squirrel Reference Manual] for a more expedient learning experience aimed at developers. | ||
== [https://sigwiki.potato.tf/index.php?title=An_Introduction_to_Squirrel Getting Started] == | == [https://sigwiki.potato.tf/index.php?title=An_Introduction_to_Squirrel Getting Started] == | ||
While it's possible to compile the Squirrel source code into binaries with which you can test your code outside of a Source game, simply launching a game and executing your script is much simpler and allows | While it's possible to compile the Squirrel source code into binaries with which you can test your code outside of a Source game, simply launching a game and executing your script is much simpler and allows you to start tinkering with Squirrel quicker, so that's what we'll do for the duration of the guide. For guides on VScript itself, the VDC has an excellent collection: | ||
* [https://developer.valvesoftware.com/wiki/VScript_Fundamentals VScript Fundamentals] | * [https://developer.valvesoftware.com/wiki/VScript_Fundamentals VScript Fundamentals] | ||
* [https://developer.valvesoftware.com/wiki/Entity_Scripts Entity Scripts] | * [https://developer.valvesoftware.com/wiki/Entity_Scripts Entity Scripts] | ||
Line 24: | Line 24: | ||
printl("Hello World!"); | printl("Hello World!"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This prints the text "Hello World!" to console, we'll cover what all this means later, for now this is just to make sure you have a set up to test with as you read through the guide. | |||
Revision as of 23:49, 26 October 2023
Overview
This is a relatively brief beginner's guide to the Squirrel language (v3.2) aimed at people with little to no programming experience. While this guide is intended to be used by people wanting to learn VScript for TF2, it doesn't cover anything regarding how to use VScript itself.
If you already have experience with C-like languages or programming in general I would recommend you visit the Squirrel Reference Manual for a more expedient learning experience aimed at developers.
Getting Started
While it's possible to compile the Squirrel source code into binaries with which you can test your code outside of a Source game, simply launching a game and executing your script is much simpler and allows you to start tinkering with Squirrel quicker, so that's what we'll do for the duration of the guide. For guides on VScript itself, the VDC has an excellent collection:
To get set up, navigate to your tf/ directory and add a scripts/vscripts folder if it doesn't already exist and create a file with any name with the extension .nut. You should have a location something like this: C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\scripts\vscripts\testing.nut
Go ahead and launch your favorite Source game which supports VScript and load into any map on a local server, then bind any key to "script_execute testing". For example: bind 5 "script_execute testing"
Tab out of your game, open your .nut file and type:
printl("Hello World!");
This prints the text "Hello World!" to console, we'll cover what all this means later, for now this is just to make sure you have a set up to test with as you read through the guide.