Voice of the Citizens

Voice of the Citizens

Not enough ratings
Scripting for Dummies (Basic)
By Carl Gustav Jung and 1 collaborators
Scripting isn't hard. You can create basic profiles without being a programmer.
   
Award
Favorite
Favorited
Unfavorite
Introduction
I'll be using C# to script. Bla bla
Requirements
Visual Studio 2015 or Visual Studio Code
Setting up the Scripting Environment
Well, what is this all about?

This is all about how do you script. So let's start with what do you need to start scripting?

You can either script using Visual Studio 2015 or Visual Studio Code, they both are great and suitable for scripting.

*How to get Visual Studio 2015 or Visual Studio Code?

It is easy, trust me it is! All you have to do is go to https://www.visualstudio.com/ and download either Visual Studio 2015 or Visual Studio Code


*Let's walk through Visual Studio 2015 *COMMUNITY* installation guide:

  • Once you have downloaded the installer, run it.
  • You will be asked where the installation files should be located at.
  • Then you will come across the installation type, for VOTC scripts you only need the default installation type.

  • Now after the installation is done, your scripting journey is about to start!

// Vs will be continued tomorrow ;3

*Now let's walk through Visual Studio Code installation guide:


  • Downloaded it, eh? Great! Run it!




Script Template
This is the basic layout of the Script Template C# Project.
  • Every Script requires a directory called "Languages" with those exact contents.
  • Each Class contains the same commands but in different languages (if translated)
  • VOTC will automatically pull the correct Language based on the user's selected language.
  • The Resources folder contains the Badge.jpg, which is the Image that's displayed on the Workshop, and any other files like Libraries or files you need. Eg. A file that saves configs of your script if needed.
  • The UserCode folder contains other code files. Don't add new classes to the root, add them in there.
  • Script.cs contains all the logic.


Here is the current Script.cs Template as of January 10th 2016
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Input; using CoreSystems; using CoreSystems.Helpers; using ScriptTemplate.Languages; public class Script { public static Dictionary<string, Action> Commands; public static void Start() { Kernel.OutputList.Insert(0, "Script Loading..."); Commands = GetCommands(); Kernel.SpeechRecognizer.LoadGrammar(Commands.Keys.ToList()); Kernel.TextToSpeech.SpeakAsync("Script Activated!"); Kernel.OutputList.Insert(0, "Script Activated!"); } public static Dictionary<string, Action> GetCommands() { switch (Kernel.Language) { case Lang.English: return English.Get(); case Lang.German: return German.Get(); case Lang.Spanish: return Spanish.Get(); case Lang.French: return French.Get(); case Lang.Italian: return Italian.Get(); case Lang.Portuguese: return Portuguese.Get(); case Lang.Japanese: return Japanese.Get(); case Lang.Chinese: return Chinese.Get(); default: return null; } } public static bool Execute(string command) { Action action; if (Commands.TryGetValue(command, out action)) { action.Invoke(); return true; } return false; } public static void KeyDown(Key key) { switch (key) { default: break; } } public static void KeyUp(Key key) { switch (key) { default: break; } } public static void Unload() { Kernel.TextToSpeech.SpeakAsync("Script Deactivated!"); } }

Download

There is no download required. You have the complete project (alway's up to date) in your STEAM\STEAMAPPS\COMMON\VOTC\Scripts\ Directory!
Writing your first basic Script!
Testing your Script
Step 1:
Go to your VOTC install, open the Scripts folder and create a new directory with the name of your script. Don't include special characters.

Step 2:
Copy the entire Script project into that folder. Include every file and folder.

Step 3:
Start VOTC. If you did everything right, you'll have your script show up in the "Available Scripts" section.

Step 4:
Say "activate [your script folder name]" and use your script. If there are errors in your script, you have to fix them and repeat from step 2.

[Add YouTube Video Tutorial "Testing your Script" here]
Uploading your Script to the Workshop
// Add link to Workshop Guide here.