Difference between revisions of "Visual Studio Code"

4,166 bytes added ,  13:13, 1 February 2018
Introduced usage and compilation guide
imported>Qazaaq
(added link to other editors)
imported>ChikkenChazer
(Introduced usage and compilation guide)
Line 12: Line 12:


===Install packages===
===Install packages===
* Papyrus [https://marketplace.visualstudio.com/items?itemName=plankton020.papyrus]
* Papyrus [https://marketplace.visualstudio.com/items?itemName=plankton020.papyrus] (syntax highlighting)


==Usage==
==Usage==


TBD
After installing VS Code, install the Papyurs package by browsing to the package's extension page and click install or the VS Code's extension installer (CTRL+SHIFT+X)
 
If your project is using project files (.ppj) you may want to associate .ppj files as XML
Go to File > Settings and add the following to *user settings*:
 
<source lang="javascript">
"files.associations": {
    "*.ppj": "xml"
}
</source>
 
User settings should look something like this:
 
<source lang="javascript">
{
    ...
    "editor.fontSize": 13,
   
    "files.associations": {
        "*.ppj": "xml"
    }
 
    ...
}
</source>


===Compilation===
===Compilation===


TBD
If you want to compile your Papyrus scripts from within Visual Studio Code you can utilize VS Code's build and tasks system.
 
Note: Replace occurences of '''<GAME-DIRECTORY>''' with the path to the directory where your game is installed (Eg.: '''C:\Program Files (x86)\Steam\steamapps\common\Fallout 4''')
 
====Compile single file using default build task====
 
# First add the [[#Files|ScriptCompileDevVS.bat]] to your '''<GAME-DIRECTORY>\Data\Scripts\Source\User''' directory. The bat file contains basic compiler configuration for development.
# If not exists create a directory named '.vscode' (without quotes) in your '''<GAME-DIRECTORY>\Data\Scripts\Source\User''' directory.
# Add the file [[#Files|tasks.json]] in the new .vscode directory.
# In tasks.json make sure the directory paths in the windows.command property are correct.
# Save tasks.json
 
Now, you may test to see if everything is working as expected by opening one of your .tsc files. Press CTRL+SHIFT+B (Run Build Task) to compile.
The built-in terminal should automatically open and output the results.
If everything has been configured correctly you should see the compilation succss message.
 
Tasks can be tweaked to better suit your particular needs. Please consult the documentation for more information: https://code.visualstudio.com/docs/editor/tasks
 
For example you may create a task that runs the compiler based on a [[Papyrus project file (.ppj)|projects]]
You may also create a task for each step in the workflow (development, release, final etc.)
 
====Compile file on CTRL+S====
 
If you want to compile the edited file every time you save the file (CTRL+S) you can add a hook in keybindings.json
 
1. Choose File > Preferences > Keyboard Shortcuts
2. Click the keybindings.json link at the top of the screen (below the search input)
3. In your keybindings.json add the following JSON object to the JSON array (between the brackets)
 
<source lang="javascript">
    {
        "key": "ctrl+s",         
        "command": "workbench.action.tasks.build",
        "when": "editorLangId == papyrus"
    }
</source>
 
This will run the build task for the currently edited Papyrus file each time you save the file using the CTRL+S shortcut.
Please note that the task will not run if save is triggered from elsewhere in VS Code (eg. Menu - File > Save)
 
Read more about keybindings here: https://code.visualstudio.com/docs/getstarted/keybindings
 
===Files===
 
'''ScriptCompileDevVS.bat'''
 
<source lang="text">
set compilerPath=%2
set gameDirectory=%~3
 
%compilerPath% %1 -f="%gameDirectory%\Data\Scripts\Source\Base\Institute_Papyrus_Flags.flg" -i="%gameDirectory%\Data\Scripts\Source\User;%gameDirectory%\Data\Scripts\Source\Base" -o="%gameDirectory%\Data\Scripts"
</source>
 
'''.vscode/tasks.json'''
 
<source lang="javascript">
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile Papyrus Script (development)",
            "type": "shell",
            "windows": {
                "command": ".\\ScriptCompileDevVS.bat '${file}' 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Fallout 4\\Papyrus Compiler\\PapyrusCompiler.exe' 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Fallout 4'",
            },
            "presentation": {
                "reveal": "always"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
</source>
 


==See Also==
==See Also==
*[[:Category:Text Editors|Other Text Editors]]
*[[:Category:Text Editors|Other Text Editors]]