Not to be confused with the Visual Studio Community/Pro this info is intended to get much-needed code complete and code info on text hover, basically the general quality of life for working with XML, specifically with X4 Scripts in the MD and AiScripts folders.
Lets Begin
Tip - create a shortcut too or symbolically link the XTools's files into your working directory and making a handy script to read the CAT files from your main X4 Game directory and extract them into your modding environment as this will save you time.
Example:
For this part, you are going to want to have VSCode & Java SDK 8/Newer installed or Jave Runtimes (JRE) and that you have VSCode's Java path configured in the settings.xml.
ou can open up CMD and type
Code: Select all
java -version
One of the ways I like to quickly get JDK (if you go down that route) up and going system-wide is making the changes to the System Environment rather than the application.
To set things up as a system environment path you need to open View Advanced System Settings, Then open the "Environment Variables" at the bottom of the dialogue box which appears. Then you under the 'System Variables' click "New" give a name of JAVA_HOME & then browse to the JDK working directory you have installed.
Example:
The Magic Touch (setting up VSCode for your mod)
Tip: root= Path to your X4 Directory (where x4.exe is located)
Tip: "schemaLocation=" does not affect your mod at all, so you can set that any path you like where your XSD schema files are located.
- Install XML RED HAT - extentsion (Unsure how to set this up? and use Watch this!)
Read the requirements as you will need Java JDK setup in VSCode or on your system for this to work correctly.
If you're working with existing game scripts that were extracted into their original directories you have code lookup and everything working.
Now if you're working inside custom mod we need to configure Scheme locations for MD scripts and/or Aiscripts depending on which your mod uses.
MD Scripts
The basics are as follows, - Copy file 'root/md/md.xsd' into your mods 'md' folder Like So
- Open your copied 'md.xsd', change line 4 so that the location points to the "root\libraries\md.xsd"
There are a couple of methods for this -
1. Be smart and use the existing directory depth variables
If you had your scripts located in 'root\extentsions\mymod\md' you would need to go up three levels to reach the root dir as the md.xsd is located in a subfolder of your mod.Make sense. You can add more of these "..\" if located somewhere else but this code should work if you keep your mod in the extension folder like a normal mod.Code: Select all
<xs:include schemaLocation="..\..\..\libraries\md.xsd" />
2. Change the location to a direct path, for example, my setup would look like -AiScriptsCode: Select all
<xs:include schemaLocation="C:\Program Files (x86)\Steam\steamapps\common\X4 Foundations Dev\libraries\md.xsd" />
- Copy file 'root/aiscripts/aiscripts.xsd' into your mods 'aiscripts' folder.
- Open your copied 'aiscripts.xsd', change line 4 so that the location points to the "root\libraries\aiscripts.xsd"
Same as the MD Scripts methods you can do this in the following ways -
1. Be smart and use the existing directory depth variables
If you had your scripts located in 'root\extentsions\mymod\aiscripts' you would need to go up three levels to reach the root dir as the aiscripts.xsd is located in a subfolder of your mod.Just the like MD Scripts the process is the same pretty much.Code: Select all
<xs:include schemaLocation="..\..\..\libraries\aiscripts.xsd" />
2. Change the location to a direct path, for example, my setup would look like -Code: Select all
<xs:include schemaLocation="C:\Program Files (x86)\Steam\steamapps\common\X4 Foundations Dev\libraries\\aiscripts.xsd" />
MD
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<mdscript name="MyScriptName" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
DO STUFF
</mdscript>
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<aiscript name="MyScriptName" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="aiscripts.xsd">
DO STUFF
</<aiscript>
I host a public URL for now which allows doing this via HTTP:// over the internet.
The website is pretty bland for now, I may move it onto an external host it is running simply on my machine at home right now. So If my PC is offline so will this be.
Useful Features provided as a side effect of hosting the libraries.
http://x4dynlib.access.ly/scriptproperties.html
http://x4dynlib.access.ly/jobeditor.html
In order to use this public URL for access to an online XSD library (you will still to enable code-complete in your IDE (editor of choice), any XSD locations simply use
Code: Select all
xsi:noNamespaceSchemaLocation="http://x4libonline.ddns.net\libraries\aiscripts.xsd"
Code: Select all
xsi:noNamespaceSchemaLocation="http://x4libonline.ddns.net\libraries\md.xsd"
- Install IIS from control panel > programs > turn windows features on or off
- Navigate too C:\inetpub\wwwroot and dump the extracted scriptproperties.html, jobeditor.html & libraries folder into it like so
- Access in any web browser using 127.0.0.1\scriptproperties.html, e.t.c
How to host that online public well that is on you, me I just used my routers built-in dynamic DNS with a No-ip.com free domain name.
VSCode Extentsions
https://github.com/Cgettys/X4CodeComplete - Suppliment extension provides very useful extra completion specific for X4 Foundations.
https://marketplace.visualstudio.com/it ... ohnson.xml - Suppliment to XML RED HAT, a few niche features.
https://marketplace.visualstudio.com/it ... scode-diff - Very fast two file differential compare.
You just do the same thing except you replace the XSD name with whatever one has the code complete and info for that kind of script.