I wanted to share a little information for those that are perhaps like me, new to x4 scripting by using visual studio. (Not sure if this information exists somewhere or if anyone needs it at all)
This will give you code complete for scripting
First thing you need to do is download Visual studio community edition, this is a free version, requires if memory serves a microsoft account (also free), see included link.
https://visualstudio.microsoft.com/vs/community/
After installing and running, for those that are not used to VS you start by creating a project from the "File->New->Project" (sc: CTRL+SHIFT+N)
This should give you a window for creating a new project that includes some details that really are not important for the work of creating X4 scripts, the window contains on the left side the project template group and in the center the project type, selecting something simple like "Windows Desktop" on the left side and "Console App" in the center should give you a pretty stripped down template.
Just write in a name for the project (f.e. X4Scripts) and have everything else on the default parameters, press ok. (For advanced stuff you could go into Source control and that way could check in your changes and keep a change history but lets not go there since it can be complicated stuff)
This should drop you back to the main VS window, on your right side you should see the "Solution explorer" window, with something like Solution 'X4Scripts' (1 project) and there below 'X4Scripts', then in there Dependencies (No need to worry about that since it is not used) and then Class1.cs (Select and delete this file since it is not used.)
New project window looks something like this.
New project
Now here comes the fun part, for code complete to work we need to have the cat files exported all .xsd files from the md and the aiscript directory into a location that can be pointed to.
Start by right clicking the project "X4Scripts" the second line in the "Solution Explorer" and click "Add->New Folder" and name it MdScripts, right click that folder and "Add->New Folder" and give that a name that you intend to name your mod in my case I will call it "Signal_Reader", right click the mod folder and "Add->New folder" and create a folder called "md" or "aiscript" depending on the type of script you are working with, in my case I will call it "md", this should give you a folder structure of "MdScripts->Signal_Reader->md", now right click the "Signal_Reader" folder and "Add->New Item"(sc: CTRL+SHIFT+A) select "XML file" and give it the name "content.xml", this is where you would insert all your content information (this is really not needed in there since you are mostly working with the script itself for code complete, but not bad to have in your project for future use), now right click the "md" folder and "Add->New Item" select "XML file" and give it the name of the script and add _MD or something to the back, giving the name for my example "Signal_Reader_MD.xml", so this is the file you would write your script in.
Small run down of what has been done.
Create a project something simple and clean up unused files and folders.
Add folder for MdScripts in the root of the project (this is where your mods will go)
Add a folder for your mod in the MdScripts folder with the name of your mod
Add a folder called md in your mod folder
Add a content.xml file to your mod folder (Optional)
Add a your_mod_MD.xml file to your mods md folder.
Your setup should be something like this.
Project file structure
Now comes the part where you add the file that will give you the code complete.
First you need to add the file md.xsd that is in your extracted X4 cat files folder, in there you should find a directory called md and in there a file called md.xsd, this file needs to be added to your mods md directory, easy way to do that is to right click the md folder for your mod in visual studio and click "Add->Existing Item"(sc: SHIFT+ALT+A), navigate to the md folder of where you extracted the x4 cat files and select the file md.xsd.
Next thing you need to do is to modify this file you just added md.xsd so it points to where the rest of the xsd files that got extraced from the cat files, this one is pretty much just a link to the actual md.xsd file that is located in the libraries folder where your cat files were extracted.
So right click the md.xsd file and click "View Code" (sc: Select it and press F7) there you should see a line that is pointing to a file called md.xsd in the libraries folder, something like this <xs:include schemaLocation="../libraries/md.xsd" /> replace the schemaLocation to the location of the libraries folder that you extracted from the cat files, f.e lets say you extracted the cat files to a folder on your C: drive called "c:\X4ExtratedCats" then you would use that for your line, giving you <xs:include schemaLocation="c:\X4ExtratedCatslibraries\libraries\md.xsd" /> (Notice that I am using \ instead of / since it is pointing to a hard location on the hard drive). Save your changes in the md.xsd file and this should give you code complete with visual studio.
This should make the md.xsd file look like this :
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:include schemaLocation="c:\X4ExtratedCatslibraries\libraries\md.xsd" />
</xs:schema>
Code: Select all
<xs:include schemaLocation="c:\X4ExtratedCatslibraries\libraries\aiscripts.xsd" />
Code complete