Write Retold XS scripts with Visual Studio Code
By Yeebaagooon · retold
Set up an editor-assisted XS workflow and connect written code with Retold’s scenario trigger tools.
By Yeebaagooon
created 28-Aug-2024
This article is for those wanting to write XS. I will walk you through how to install Visual Studio Code (VSC), the XS extension for AoM: Retold, and show this in action.
I’m aiming this article at new coders, as this program will be the best way for you to learn XS code. You don’t have to use VSC, any advanced notepad program such as notepad+ or sublime will do – however only VSC can use the XS extension supplied by the game and will make life for new coders much easier. So if you have to get used to one program it might as well be this one.
Step One: Installing VSC
VSC is free. You can be install it by accessing the microsoft store.
- Type ‘microsoft store’ into your start bar.
- Search for ‘VS Code’ then click on ‘Visual Studio Code’.
- You can now click the download button and the program will install.
Step Two: Installing the XS extension
Now open VS Code.
- Click ‘extensions’.
- Click the three dots at the top of the extensions tab.
- Select ‘install from VSIX’ from the dropdown.
- Navigate to C:\Program Files (x86)\Steam\steamapps\common\Age of Mythology Retold\vscodeextensionretail (or similar) and select xs.vsix. This file is zipped so you may have to extract it first.
Step 1
Step 2
Step 3
Step 4
Step Three: Using VSC
The XS extension is now installed.
- Open a new file with Ctrl + N
- Click on ‘select a language’, type in ‘xs’ and select ‘xs’.
- You can now write your script with the tool active.
Now if you start to type some commands such as ‘tr’ or ‘unit’ or ‘kb’ VSC will give you a dropdown list of valid commands.
Selecting these commands now briefly explain what it does, as well as the correct format and form of parameters.
Typing in a command with the XS extension fully loaded explains all arguments required.
As you can see this is super useful for those aspiring to learn XS! Good luck, and remember XS is a case sensitive language.
A brief ending note: You can use special commands such as // to start a comment (so the line is not read as code, helpful for annotations). /* and */ also do the same but work as a block, so new lines between those commands will be commented out.
Below is a basic example of how a trigger is formatted in XS.
rule Test_Message
highFrequency
active
{
if(xsGetTime() >= 1){
trMessageSetText("Hello beautiful!", 5);
xsDisableSelf();
}
}
This is a really useful tip when you start out. If you are not sure what code would look like but you know what the triggers are – then simply create the triggers in a blank map. Playtest the map.
You will then find the entire trigger code is output in direct XS code.
You can grab that code by checking the corresponding file: trigtemp.xs
Be sure to seek guidance in our forums with any XS questions or queries you may have.
Back to the XS section
Source: Yeebaagooon · HeavenGames