X4CodeSense
v0.5.0X4: Foundations scripts: checks, schema elements, expression types, scripts, cues and texts.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
check Check scripts
Checks X4 scripts and patches as the X4CodeSense editor and x4-script-check do: well-formedness, the game schemas, expressions, variables, names, cues, scripts and texts referred to; and library files that name their schema in xsi:noNamespaceSchemaLocation against it. Returns the findings with their quick fixes (edits to apply), and counts. Run it after every change to an md or aiscripts script or a patch, and fix what it reports; with text, check a draft before writing it.
| Parameter | Type | Description |
|---|---|---|
paths * | array | Files and folders. A folder is checked as x4-script-check checks it: the md, aiscripts and libraries folders in it and one level deeper, so an extension or a folder of extensions. Relative paths are t… |
severity | string | The least severe finding to report: error, warning, info or hint (the default, all). |
text | string | The text to check instead of what is on disk, for one file in paths: what you are about to write there. |
describe_element Describe an element
An element of the Mission Director or AI script schema, from the game’s md.xsd or aiscripts.xsd, or of a library file’s schema (libraries.xsd for jobs.xml, unlocks.xsd, …): its documentation, its attributes (type, required, default, allowed values, whether the value is an expression) and the child elements it allows. Use it before writing an element or attribute you are not sure of, instead of searching md.xsd, aiscripts.xsd or common.xsd: it follows their types, groups and includes.
| Parameter | Type | Description |
|---|---|---|
name * | string | The element name: set_value, find_ship, create_order, cue. |
attribute | string | One attribute in full: every allowed value with its documentation. Without it, every attribute with the first values by name. |
library | string | Instead of script, the schema a library file names in xsi:noNamespaceSchemaLocation, by its file name: libraries (jobs.xml, ships.xml, …), unlocks, factions. |
parent | string | The parent element, for an element declared differently in different places, such as param or actions. |
script | string | md for Mission Director scripts, aiscripts for AI scripts; or give library instead. |
expression_type Type of an expression
What a keyword or a property chain of the expression language yields, step by step, from the game’s scriptproperties.xml: player.ship, player.ship.sector, event.param; and the properties of the result with their types. Or a datatype’s properties. A variable has no type here, its type comes from the script around it: the step after it is matched against the properties of every datatype. Use it before writing a property chain you are not sure of, instead of searching scriptproperties.xml.
| Parameter | Type | Description |
|---|---|---|
datatype | string | Instead of an expression, a datatype: ship, sector, list, faction. |
expression | string | A keyword and its properties: player.ship.sector. |
filter | string | Only the properties of the result whose names contain this text, with their descriptions, also those of the types derived from it. Without it, its own and inherited properties as name → type. |
script | string | The script kind, for the keywords of one kind only: md (the default) or aiscripts. |
find Find scripts and cues
Mission Director scripts, AI scripts, cues, libraries and interrupt library items (actions, handlers, conditions) of the game, its DLCs and the extensions, by name: whole names first, then those starting with the query, then those containing it; the extensions’ before the game’s among equals. A query with a dot matches qualified names: md.Setup.Start. When no name contains the query, a few that have its letters in order. Use it instead of searching the files for a cue or script name.
| Parameter | Type | Description |
|---|---|---|
query * | string | A name or part of one. |
limit | integer | The most names to return; 50 by default. |
definition Go to definition
Where what is named at a place of a script is defined, as the editor’s go to definition finds it: a cue, script, library, label, variable, order, text, element or attribute of the schema, property of scriptproperties.xml. Each place with its line of text.
| Parameter | Type | Description |
|---|---|---|
column * | integer | The column, from 1. |
file * | string | The script or patch. |
line * | integer | The line, from 1. |
references Find references
Every place that names what is named at a place of a script, in the game, its DLCs and the extensions, as the editor finds them: who signals a cue, includes a library, runs a script. Each place with its line of text. Use it instead of searching the files for a name.
| Parameter | Type | Description |
|---|---|---|
column * | integer | The column, from 1. |
file * | string | The script or patch. |
line * | integer | The line, from 1. |
hover Describe a place
What the editor’s hover shows for a place of a script or patch: an element or attribute with its documentation from the schema, a step of a property chain with its type and description from scriptproperties.xml, a variable with its type and where the type comes from, a cue or script with where it is defined, a {page, id} text as the game shows it. Use it to understand a line of an existing script, the game’s included, instead of looking each part up in the schemas, scriptproperties.xml or the t folders.
| Parameter | Type | Description |
|---|---|---|
column * | integer | The column, from 1. |
file * | string | The script or patch. |
line * | integer | The line, from 1. |
text Look up texts
Texts of the game and the extensions, as the game shows them, references resolved: {page, id} in a language; the texts of a page; or the texts that contain some words. Use it instead of searching the t folders: for what a {page, id} says, or to find an existing text to reuse.
| Parameter | Type | Description |
|---|---|---|
id | integer | The text id on the page; without it, the texts of the page. |
language | string | The language number, 44 for English; by default the one the server was started with. |
limit | integer | The most texts to return for a page or a search; 20 by default. |
page | integer | The page id. |
search | string | Instead of page and id: words that must all be in the text, without regard to case. |
status Status
What the server read: the game folder, the extension folders, how many scripts and texts, and the problems met reading them.