Editing
An Introduction to Squirrel
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== [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 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 aimed at developers. == [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 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/Entity_Scripts Entity Scripts] * [https://developer.valvesoftware.com/wiki/Team_Fortress_2/Scripting/Script_Functions Script Functions] * [https://developer.valvesoftware.com/wiki/Team_Fortress_2/Scripting/Script_Functions/Constants Constants] * [https://developer.valvesoftware.com/wiki/Team_Fortress_2/Scripting/VScript_Examples/en VScript Examples] 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. (Mine will be named testing.nut) You should have a location something like this: <pre>C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\scripts\vscripts\testing.nut</pre> 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 <code>"script_execute testing"</code>. For example: <code>bind 5 "script_execute testing"</code> Tab out of your game, open your .nut file and type: <syntaxhighlight lang="c#" line="1" start="1" style="font-weight:bold;> printl("Hello World!"); </syntaxhighlight> <code>'''printl'''</code> is a function that prints to the developer console, we'll go over what functions are and the syntax for it later in the guide, for now just follow along. After saving the file and pressing our script button in-game, you'll see <code>Hello World!</code> in console. You just made your first program in VScript! To get started with the guide, choose a chapter in the table below. Make sure to tinker with the examples in the guide to see first hand how Squirrel works! Good luck! <hr> {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0;" |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable mw-collapsible mw-collapsed" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="padding: 25px; background-color: #303030; color: white; border: 2px solid black" | Chapters |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Variables Variables] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Comments Comments] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Data_Types Data Types] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Operators Operators] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Expressions Expressions] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Intro_to_Functions Intro to Functions] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Intro_to_Objects Into to Objects] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Scopes Scopes] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Control_Flow Control Flow] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Exceptions Exceptions] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Enums Enums] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Arrays Arrays] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Tables Tables] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Functions Functions] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Generators Generators] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Delegation Delegation] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Weak_References Weak References] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Classes Classes] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Inheritance Inheritance] |} |- | colspan="1" style="padding: 0; margin: 0; width: 100%;" | {| class="wikitable" style="margin: 0 auto; width: 100%; padding: 0; border: none;" ! colspan="1" style="border: 1px solid black; padding-right:64px; background-color: #606060; color: #111111; height: 35px;" | [https://sigwiki.potato.tf/index.php/Squirrel_Metamethods Metamethods] |} |} |}
Summary:
Please note that all contributions to SigMod are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
SigMod:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
British English
Views
Read
Edit
Edit source
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information