GitHub-TC / EmpyrionScripting

Displays various informations directly and live on LCD screens and will support conveyor and construction control
GNU General Public License v3.0
35 stars 5 forks source link

# Empyrion Scripting English part of this ReadMe.md

Installation

  1. Downloade die EmpyrionScripting.zip Datei vom aktuellen https://github.com/GitHub-TC/EmpyrionScripting/releases
  2. UnZip die Datei in dem Verzeichnis Content\Mods directory

Installation für SinglePlayer

  1. Downloade die EmpyrionScripting.zip Datei vom aktuellen https://github.com/GitHub-TC/EmpyrionScripting/releases
  2. UnZip die Datei in dem Verzeichnis Content\Mods directory
  3. Das Spiel MUSS dann ohne EAC gestartet werden damit die Mods geladen werden

Wofür dient diese MOD?

Echte Spielinhalte direkt auf einem LCD ausgeben

Eine dem Struktur 'LCDInfo-Demo' findest du im workshop https://steamcommunity.com/workshop/filedetails/?id=1751409371

Hilfe

YouTube video;

Beginners guide (english):

Tutorials

Beispiele

Allgemein: Benötigt werden mindestens 2 LCD und mindestens 1 Container

  1. LCD 1 (Eingabe) wird mit der Abfrage programmiert siehe Beispiele unten. Der Namen des LCDs im ControlPanel MUSS mit "Script:" beginnen.
  2. LCD 2 (Ausgabe) Muss eindeutigen Namen haben z.B. "LCD Alle Erze"
  3. Jeder Kontainer der eine Information ausgeben soll, muss einen eindeutigen Namen haben

Unten stehen die ID Nummer für Erze und Barren.
Einige Funktionen benötigen ein Komma"," andere benötigen Simikolon ";".
Alles in "" sind Texte und nicht mit anzugeben.
Einzelne ' sind mit anzugeben.
Man kann eine Information auch auf 2 LCD's anzeigen lassen dannsortedeach bei Targets:Name LCD;Name LCD2
Man kann eine Information auch auf n LCD's anzeigen lassen dann bei Targets:LCDAusgabe
Man kann eine Information auch auf n LCD's anzeigen lassen welche schon im ScriptLCD Namen angegeben sind Script:LCDAusgabe

Man kann auf einem LCD auch den Inhalt verschiedner Kisten anzeigen lassen!


Sprache, Format, Zeit der Ausgaben

Die Sprache, Uhrzeitoffset und Anzeigeformate kann man mit einem LCD einstellen welches man 'CultureInfo' benennt. Etwaige Fehler bei der Angabe werden in einem LCD mit dem Namen 'CultureInfoDebug' angezeigt.

Dabei kann man in der 'CultureInfo' folgendes angeben:

{
  "LanguageTag": "de-EN",
  "i18nDefault": "English",
  "UTCplusTimezone": 2
}

LanguageTag: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c

Was ist in der Kiste/Container/ContainerController/MunitionsKiste/Kühlschrank

Eingabe im LCD 1 (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT Optional"
{{items E.S '"Name der Kiste"'}}
{{Count}}{{Name}}
{{/items}}

Bsp:

Targets:LCD Alle Erze
Meine Erze
{{#items E.S 'Alle Erze'}}
{{Count}}{{i18 Key}}
{{/items}}

Ausgabe aller Erze in der Basis/Schiff/HV/CV

Eingabe im LCD (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#test ID in '4296,4297,4298,4299,4300,4301,4302,4317,4318,4332,4341,4345'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Bsp:

Targets:LCD Alle Erze
Meine Erze
{{#each E.S.Items}}
{{#test Id in '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Ausgabe aller Barren in der Basis/Schiff/HV/CV

Eingabe im LCD (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#each E.S.Items}}
{{#test Id in '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Bsp:

Targets:LCD Barren
Alle meine Barren in der Basis:
{{#each E.S.Items}}
{{#test Id in '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Ausgabe dieser per ID festgelegten Produkte (hier sind es alle Barren die es gibt im Spiel)

Eingabe im LCD (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#itemlist E.S.Items '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Bsp:

Targets:LCD Alle Barren im Spiel
Alle Barren im Spiel:
{{#itemlist E.S.Items '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Anzeige eines bestimmten Produktes in der Basis/Schiff/HV/CV

Eingabe im LCD (alles ohne "")
Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#itemlist E.S.Items '4297'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Bsp:

Targets:LCD EISEN ERZ
Meine EisenErz und Barren
{{#itemlist E.S.Items '4297,4320'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Welche Erze sind alle, bzw. nur noch X Anzahl über

Hier werden alle Erze angezeigt wo nur 1-1000 auf der Basis vorhanden ist.

{{#itemlist E.S.Items '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{#test Count geq 1}}
{{#test Count leq 1000}}
{{Count}} {{i18n Key}}
{{/test}}
{{/test}}
{{/itemlist}}

Hier werden alle Erze angezeigt die nicht mehr auf der Basis sind

{#itemlist E.S.Items '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{#test Count leq 0}}
{{Count}} {{i18n Key}}
{{/test}}
{{/itemlist}}

Vordefinierte ID Listen

Diese Listen können geändert werden oder durch neue Einträge erweitert werden. Dazu kann einfach der Abschnitt "Ids" in der Datei [EGS]\Saves\Games\[SaveGameName]\Mods\EmpyrionScripting\Configuration.json geändert werden.

Hinweis: Um den Originalzustand wieder herzustellen kann der Abschnitt "Ids" aus der Datei geöscht werden. Die Mod trägt dann hier die im Programm hinterlegte Standardkonfiguration wieder ein.

Folgende Listen können über "Ids.[NameDerListe] im Standard abgerufen werden.

Für das deconstruct script zu löschende Blöcke:

Die Listen beginnen und enden mit einem Komma so das sie einfach mit dem Befehl concat kombiniert werden können.

(concat @root.Ids.WeaponHV @root.Ids.WeaponSV @root.Ids.WeaponCV)
oder
(concat '1234,5568' @root.Ids.ArmorMod)

Welcher Spieler ist auf der Basis/Schiff gerade aktiv

Eingabe im LCD (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"Eingabe im LCD (alles ohne "")
"TEXT optional"
{{#each P.Players}}
 "-" {{Name}}
{{/each}}

Bsp.

Targets:LCD Info W1
Player:
{{#each P.Players}}
 - {{Name}}
{{/each}}

Datum und Uhrzeit anzeigen lassen

Eingabe im LCD (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"Eingabe im LCD (alles ohne "")
"TEXT optional"
{{datetime}}

{{datetime 'HH:mm'}}

{{datetime 'dd MMM HH:mm:ss' '+7'}}

Bsp.

Targets:LCD UHRZEIT
Wie spät ist es?
{{datetime}}

{{datetime 'HH:mm'}}

{{datetime 'dd MMM HH:mm:ss' '+7'}}

SCROLLEN:

Wenn zu viele Produkte nicht angzeigt werden können, dann kann man auch Scrollen Hier werden 5 Produkte angezeigt mit 2 Sekunden Scrollgeschwindigkeit, wenn mehr als 5 Items zur Verfügung stehen.

{{#scroll 5 2}}
{{#items E.S '"Name der Kiste"'}}
{{Count}} {{i18n Key}}
{{/items}}

Bsp.

{{#scroll 5 2}}
{{#items E.S 'Kühlschrank 1'}}
{{Count}} {{i18n Key}}
{{/items}}

{{#scroll 10 1}}
{{#each E.S.Items}}
 - [{{Id}}]:{{Name}}
{{/each}}
{{/scroll}}

Intervalle:

Es kann alles in Intervallen angezeigt werden. Hier im Beispiel wäre es ein Pfeil Man kann auch den Inhalt von 2 Kisten anzeigen lassen

{{#intervall 1}}
= = = = = = = = = = = = = = = = >
{{else}}
 = = = = = = = = = = = = = = = =>
{{/intervall}}

oder hier sind sind 2 Kisten die abwechselnd angezeigt werden.

{{#intervall 2}}
"Text optional"
{{#items E.S '"Name der Kiste"'}}
{{Count}} {{i18n Key}}
{{/items}}
{{else}}
"Text optional"
{{#items E.S '"Name der Kiste2"'}}
{{Count}} {{i18n Key}}
{{/items}}
{{/intervall}}

Bsp.

{{#intervall 2}}

Kühlschrank 1:

{{#items E.S 'Kühlschrank 1'}}
{{Count}} {{i18n Key}}
{{/items}}
{{else}}

Kühlschrank 2:

{{#items E.S 'Kühlschrank 2'}}
{{Count}} {{i18n Key}}
{{/items}}
{{/intervall}}

Farbe Schrift und Hintergrund, Schriftgrösse und Intervall

Im folgendem Beispiel wechselt alle 5 Sekunden das Wort "Hallo" und "Welt" dann wechselt auch alle 5 Sekunden die Schriftgrösse Es wechselt jede Sekunde die Schriftfarbe und jede Sekunde der Hintergrund

{{#intervall 5}}
Hallo
{{else}}
Welt
{{/intervall}}

{{#intervall 5}}
{{fontsize 8}}
{{else}}
{{fontsize 15}}
{{/intervall}}

{{#intervall 1}}
{{color 'ff0000'}}
{{else}}
{{color '00ff00'}}
{{/intervall}}

{{#intervall 1}}
{{bgcolor 'ffff00'}}
{{else}}
{{bgcolor '000000'}}
{{/intervall}}

ERZE und BARREN IDENTIFIKATIONS NUMMER:

@root.Ids.Ore


@root.Ids.Ingots


Technical

Syntaxdocu:

Items

Items habe folgende Basisdaten

Bedingungen

Inhalte

Verschieben/Auffüllen/Verarbeiten

Lichter

Geräte

Datenaufbereitung

Block

Rechnen

LCD

Strukturen

Signale

Positionen (Struktur und Welt)

Chat

Chat (Admin only)

Teleport

JSON

{{tojson object}}

Fliegen

Hinweis: Fliegen funktioniert nur wenn kein Pilot das Schiff steuert und die Triebwerke eingeschaltet sind

Dialogfenster

DB Zugriff

Um die 'global.db' Datenbank des EmpyrionSavegames zu durchforsten und eigene Queries der Konfiguration hinzuzufügen bietet sich der SQLiteBrowser https://sqlitebrowser.org/ an.

Der Query stehen Standardmäßig folgende Parameter zur Verfügung:

Folgende Queries stehen zur Verfügung:

Entities

SELECT * FROM Structures 
JOIN Entities ON Structures.entityid = Entities.entityid
JOIN Playfields ON Entities.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId)) {additionalWhereAnd}

DiscoveredPOIs

SELECT * FROM DiscoveredPOIs
JOIN Entities ON DiscoveredPOIs.poiid = Entities.entityid
JOIN Playfields ON Entities.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (Entities.isremoved = 0 AND (DiscoveredPOIs.facgroup = 0 OR DiscoveredPOIs.facgroup = 1) AND (DiscoveredPOIs.facid = @PlayerId OR DiscoveredPOIs.facid = @FactionId)) {additionalWhereAnd}

TerrainPlaceables

SELECT * FROM TerrainPlaceables 
JOIN Entities ON TerrainPlaceables.entityid = Entities.entityid
JOIN Playfields ON TerrainPlaceables.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId OR TerrainPlaceables.entityid = @PlayerId OR TerrainPlaceables.entityid = @FactionId)) {additionalWhereAnd}

TerrainPlaceablesRes

SELECT * FROM TerrainPlaceables
JOIN PlayfieldResources ON (PlayfieldResources.pfid = TerrainPlaceables.pfid AND abs(PlayfieldResources.blockx - TerrainPlaceables.blockx) <= 20 AND abs(TerrainPlaceables.blockz - PlayfieldResources.blockz) <= 20)
JOIN Entities ON TerrainPlaceables.entityid = Entities.entityid
JOIN Playfields ON TerrainPlaceables.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId OR TerrainPlaceables.entityid = @PlayerId OR TerrainPlaceables.entityid = @FactionId)) {additionalWhereAnd}

Playfields

SELECT * FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE playfields.ssid IN (
SELECT ssid FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
WHERE (DiscoveredPlayfields.facgroup = 0 OR DiscoveredPlayfields.facgroup = 1) AND (DiscoveredPlayfields.facid = @PlayerId OR DiscoveredPlayfields.facid = @FactionId)
GROUP BY playfields.ssid
) {additionalWhereAnd}

PlayfieldResources

SELECT * FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
JOIN PlayfieldResources ON PlayfieldResources.pfid = Playfields.pfid
WHERE playfields.ssid IN (
SELECT ssid FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
WHERE (DiscoveredPlayfields.facgroup = 0 OR DiscoveredPlayfields.facgroup = 1) AND (DiscoveredPlayfields.facid = @PlayerId OR DiscoveredPlayfields.facid = @FactionId)
GROUP BY playfields.ssid
) {additionalWhereAnd}

PlayerData

SELECT * FROM PlayerData 
JOIN Entities ON Entities.entityid = PlayerData.entityid
JOIN Playfields ON Playfields.pfid = PlayerData.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE ((Entities.facgroup = 0 OR Entities.facgroup = 1 OR facgroup = 0 OR facgroup = 1) AND (Entities.facid = @PlayerId OR facid = @PlayerId OR Entities.facid = @FactionId OR facid = @FactionId)) {additionalWhereAnd}

Bookmarks

SELECT * FROM Bookmarks
JOIN Entities ON Bookmarks.entityid = Entities.entityid
JOIN Playfields ON Bookmarks.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE ((Bookmarks.facgroup = 0 OR Bookmarks.facgroup = 1) AND (Bookmarks.facid = @PlayerId OR Bookmarks.facid = @FactionId)) {additionalWhereAnd}

Externe Daten

Hier mit ist es möglich externe Daten aus den AddOnAssemblys abzurufen. Welche Parameter zusätzlich benötigt werden müssen der Dokumentation der jeweiligen externen Datenquelle entnommen werden.

Bereitstellung einer DLL für die externen Daten (mit einem Beispiel aus dem EmpyrionGalaxyNavtigator)

Diese Dll muss eine Klasse welche das IMod Interface implementiert besitzen. Außerdem muss die ein Property 'ScriptExternalDataAccess' implementieren.

public class ExternalDataAccess : IMod
{
    public IDictionary<string, Func<IEntity, object[], object>> ScriptExternalDataAccess { get; }

    public ExternalDataAccess()
    {
        ScriptExternalDataAccess = new Dictionary<string, Func<IEntity, object[], object>>()
        {
            ["Navigation"] = (entity, args) => entity?.Structure?.Pilot?.Id > 0 ?         Navigation(entity) : null,
            ["MaxWarp"   ] = (entity, args) => entity?.Structure?.Pilot?.Id > 0 ? (object)MaxWarp   (entity) : null,
        };
    }

Des weiteren muss der Pfad zu der DLL in der Konfigurationsdatei des EmpyrionScripting angegeben werden. (Basis ist das Modverzeichnis des EmpyrionScripting im Savegame)

"AddOnAssemblies": [
    "..\\EmpyrionGalaxyNavigator\\EmpyrionGalaxyNavigatorDataAccess.dll"
],

Und die DLL muss an ihrem vorgesehen Platz kopiert werden (im Fall des EmyprionGalaxyNavigators in dessen Modverzeichins im Savegame) Die DLL befindet sich in dieser Datei 'EmpyrionGalaxyNavigatorDataAccess.zip' welche im ModLoaderpaket enthalten ist oder unter https://github.com/GitHub-TC/EmpyrionGalaxyNavigator/releases heruntergeladen weden kann.

Beim Aufruf der Funktionen werden die aktuelle Entität sowie die übergebenen 'args' mit übergeben. (in diesem Fall werden keine weiteren Parameter für den Zugriff auf den GalaxyNavigator benötigt)

{{#external 'MaxWarp'}}
Maximale Sprungreichweite: {{.}}
{{/external}}

Elevated Scripte (Savegame oder Adm-Strukturen)

SaveGame Scripte

Diese besondere Form von Scripten kann im SaveGame hinterlegt werden. Der BasisPfad dafür ist der [SaveGame]\Mods\EmpyrionScripting\Scripts

Dieser Pfad ist auch über @root.MainScriptPath zu erreichen.

in diesem Verzeichnis werden nach folgendem Muster Scriptdateien mit der Endung *.hbs gesucht

Hinweis: EntityType ist BA,CV,SV or HV

CustomHelpers-SaveGameScripts

Priorisierung von Scripten

Wenn viele Scripte eingebaut sind macht es Sinn, die jenigen welche nicht so häufig ausgeführt werden brauchen, herabzustufen damit die anderen Scripte häufiger ausgeführt werden. Dazu kann man VOR dem Namen eines Scripte eine Zahl von 0-9 schreiben so dass dieseses Script nur alle N Zyklen ausgeführt wird. z.B. 1Script:abc 3Script:uvw 4Script:xyz

1: abc 2: abc 3: abc, uvw 4: abc, xyz 5: abc 6: abc, uvw 7: abc 8: abc, xyz ...

Der Unterschied zwischen einem Script OHNE Nummer oder 0 und einem Script mit einer '1' ist der das Scripte mit einer Priorität >= 1 unabhängig davon laufen ob das ScriptLCD ausgeschaltet ist.

Scripte mit 0 oder ohne Nummer werden nur ausgeführt wenn das LCD eingeschaltet ist. (Hinweis: man kann die Schriftfarbe (bei Projektoren) auf transparent setzen um es "unsichtbar" zu machen)

Automatische Amount Anpassungen

Für Fuel, O2,... kann es sinvoll sein die aktuellen Werte aus der Ecf-Konfiguration (des Szenarios) zu verwenden Hierfür kann der Eintrag "EcfAmountTag" angegeben werden. Der Wert für "Amount" wird dann automatisch aus dem Item mit dem Wert des Tags ermittelt. Soll der Wert nicht automatisch ermittelt werden kann EcfAmountTag:"" angegeben werden.

Beispiele für eine automatische Ermittlung

{
    "ItemName": "EnergyCellLarge",
    "Amount": 250,
    "EcfAmountTag": "FuelValue"
}
...
{
  "ItemName": "OxygenBottleLarge",
  "Amount": 250,
  "EcfAmountTag": "O2Value"
}

keine automatische Ermittung

{
    "ItemName": "EnergyCellLarge",
    "Amount": 250,
    "EcfAmountTag": ""
}

Allgemeines

Wenn die Struktur ausgeschaltet ist oder keinen Strom hat werden keine InGameScripte von ihr ausgeführt. Somit verbrauchen "alte" oder nicht mehr benutze Strukturen auch keine Leistung der Scriptengine.

Ausführung und Leistung der Scripts einstellen

Hint: ...\Saves\Games[Savegamename]\Mods\EmpyrionScripting\Configuration.json

"SaveGameScriptsIntervallMS": 10000,
"ScriptsSyncExecution": 2,
"ScriptsParallelExecution": 4,
...
"ProcessMaxBlocksPerCycle": 200,

Are set VERY conservatively by default so as not to put the server (and the game) under load. Double the values (SaveGameScriptsIntervallMS must lower) and the scripts will run more "smoothly", but there may be micro-jerks in the game.

Whats next?

ASTIC/TC


English Version


Empyrion Scripting

Installation

  1. Download the EmpyrionScripting.zip file from the current https://github.com/GitHub-TC/EmpyrionScripting/releases
  2. unzip the file in the Content\Mods directory

Installation for SinglePlayer

  1. Download the EmpyrionScripting.zip file from the current https://github.com/GitHub-TC/EmpyrionScripting/releases
  2. UnZip the file in the directory Content\Mods directory
  3. The game MUST then be started without EAC so the mods are loaded

Whats for?

Displays various informations directly and live on LCD screens.

Get the demo structure 'LCDInfo-Demo' from the workshop https://steamcommunity.com/workshop/filedetails/?id=1751409371

Help

YouTube video;

Beginners guide (english):

Tutorials

Examples

General: At least 2 LCDs and at least 1 container are required

  1. LCD 1 (input) is programmed with the query see examples below
  2. LCD 2 (output) Must have unique name, e.g. "LCD All ores"
  3. Each container that is to output information must have a unique name

Below is the ID number for ores and ingots.
Some functions require a comma "," others require a simcard ";".
Everything in "" are texts and not to be specified.
Individuals are to be indicated.
One can also display an information on 2 LCD's then at Targets: "Name LCD"; "Name LCD2"
You can also display the content of various boxes on an LCD!


Language, format, time of the outputs

The language, time offset and display formats can be set with an LCD which is called named 'CultureInfo'. Any errors in the specification are displayed in an LCD named 'CultureInfoDebug'.

You can specify the following in the 'CultureInfo':

{
  "LanguageTag: "en-EN",
  "i18nDefault": "English",
  "UTCplusTimezone": 2
}

LanguageTag: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c

What's in the box / container / container controller / ammo box / refrigerator

Eingabe im LCD 1 (alles ohne "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT Optional"
{{items E.S '"Name der Kiste"'}}
{{Count}}{{Name}}
{{/items}}

Bsp:

Targets:LCD Alle Erze
Meine Erze
{{#items E.S 'Alle Erze'}}
{{Count}}{{i18 Key 'Deutsch'}}
{{/items}}

Output of all ores in the base / ship / HV / CV

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#test ID in '4296,4297,4298,4299,4300,4301,4302,4317,4318,4332,4341,4345'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Bsp:

Targets:LCD Alle Erze
Meine Erze
{{#each E.S.Items}}
{{#test Id in '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Output of all bars in the base / ship / HV / CV

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#each E.S.Items}}
{{#test Id in '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Bsp:

Targets:LCD Barren
Alle meine Barren in der Basis:
{{#each E.S.Items}}
{{#test Id in '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/test}}
{{/each}}

Output of these ID-defined products (here are all ingots in the game)

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#itemlist E.S.Items '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Bsp:

Targets:LCD Alle Barren im Spiel
Alle Barren im Spiel:
{{#itemlist E.S.Items '4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4333,4342,4346'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Display of a specific product in the base / ship / HV / CV

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"
"TEXT optional"
{{#itemlist E.S.Items '4297'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Bsp:

Targets:LCD EISEN ERZ
Meine EisenErz und Barren
{{#itemlist E.S.Items '4297,4320'}}
{{Count}} {{i18n Key}}
{{/itemlist}}

Which ores are all, or only X number over

Here all ores are displayed where only 1-1000 exists on the basis.

{{#itemlist E.S.Items '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{#test Count geq 1}}
{{#test Count leq 1000}}
{{Count}} {{i18n Key}}
{{/test}}
{{/test}}
{{/itemlist}}

Here all ores are displayed that are no longer based

{#itemlist E.S.Items '4296,4297,4298,4299,4300,4301,4317,4318,4332,4345,4328,4302'}}
{{#test Count leq 0}}
{{Count}} {{i18n Key}}
{{/test}}
{{/itemlist}}

Predefined ID lists

These lists can be changed or expanded with new entries. To do this, simply use the section "Ids" in the file [EGS]\Saves\Games\[SaveGameName]\Mods\EmpyrionScripting\Configuration.json be changed.

Note: To restore the original state, the section "Ids" can be deleted from the file. The mod then enters the standard configuration stored in the program again.

The following lists can be called up via "Ids.[NameDerListe] in the standard system.

Für das deconstruct script zu löschende Blöcke:

The lists begin and end with a comma so that they can be easily combined with the command concat.

(concat @root.Ids.WeaponHV @root.Ids.WeaponSV @root.Ids.WeaponCV)
or
(concat '1234.5568' @root.Ids.ArmorMod)

Which player is currently active on the base / ship

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"Input on the LCD (everything without "")
"TEXT optional"
{{#each P.Players}}
 "-" {{Name}}
{{/each}}

Bsp.

Targets:LCD Info W1
Player:
{{#each P.Players}}
 - {{Name}}
{{/each}}

Display date and time

Input on the LCD (everything without "")

Targets:"NAME DES ANZUZEIGENDEN LCD"Input on the LCD (everything without "")
"TEXT optional"
{{datetime}}

{{datetime 'HH:mm'}}

{{datetime 'dd MMM HH:mm:ss' '+7'}}

Bsp.

Targets:LCD UHRZEIT
Wie spät ist es?
{{datetime}}

{{datetime 'HH:mm'}}

{{datetime 'dd MMM HH:mm:ss' '+7'}}

SCROLLEN:

If too many products can not be displayed, then you can also scroll 5 products are shown here with 2 seconds scrolling speed if more than 5 items are available.

{{#scroll 5 2}}
{{#items E.S '"Name der Kiste"'}}
{{Count}} {{i18n Key}}
{{/items}}

Bsp.

{{#scroll 5 2}}
{{#items E.S 'Kühlschrank 1'}}
{{Count}} {{i18n Key}}
{{/items}}

{{#scroll 10 1}}
{{#each S.Items}}
 - [{{Id}}]:{{Name}}
{{/each}}
{{/scroll}}

Intervalle:

Everything can be displayed at intervals. Here in the example it would be an arrow You can also display the contents of 2 boxes

{{#intervall 1}}
= = = = = = = = = = = = = = = = >
{{else}}
 = = = = = = = = = = = = = = = =>
{{/intervall}}

or here are 2 boxes that are displayed alternately.

{{#intervall 2}}
"Text optional"
{{#items E.S '"Name der Kiste"'}}
{{Count}} {{i18n Key}}
{{/items}}
{{else}}
"Text optional"
{{#items E.S '"Name der Kiste2"'}}
{{Count}} {{i18n Key}}
{{/items}}
{{/intervall}}

Bsp.

{{#intervall 2}}

Kühlschrank 1:

{{#items E.S 'Kühlschrank 1'}}
{{Count}} {{i18n Key}}
{{/items}}
{{else}}

Kühlschrank 2:

{{#items E.S 'Kühlschrank 2'}}
{{Count}} {{i18n Key}}
{{/items}}
{{/intervall}}

Color font and background, font size and interval

In the following example, the word "Hello" and "World" changes every 5 seconds. then the font size also changes every 5 seconds The font color changes every second and the background every second

{{#intervall 5}}
Hallo
{{else}}
Welt
{{/intervall}}

{{#intervall 5}}
{{fontsize 8}}
{{else}}
{{fontsize 15}}
{{/intervall}}

{{#intervall 1}}
{{color 'ff0000'}}
{{else}}
{{color '00ff00'}}
{{/intervall}}

{{#intervall 1}}
{{bgcolor 'ffff00'}}
{{else}}
{{bgcolor '000000'}}
{{/intervall}}

ERZE und BARREN IDENTIFIKATIONS NUMMER:

@root.Ids.Ore


@root.Ids.Ingot


Technical

Syntaxdocu:

Items

Items have the following basic data

Conditions

Items

Logiccheck

(intervall)

(scroll)

(i18n)

(datetime)

DateTime format:

(move)

(lights)

(lightcolor)

(lightblink)

(light intensity)

(lightrange)

(lightspotangle)

(lighttype)

(devices)

(devicesoftype)

(setactive)

(steps)

Stringfunctions

(chararray)

(set)

(math)

(data)

(blocks)

(concat)

Devices

(gettexture)

(gettext)

(settext)

(settextblock)

(setcolor)

(setbgcolor)

(entitybyname)

(entitybyid)

(entitiesbyid)

Move/Fill/Process

Positions (structure and world)

Chat

Chat (Admin only)

Teleport

JSON

{{tojson object}}

Flying

Note: Flying only works when there is no pilot controlling the ship and the engines are switched on.

Dialog windows

DB Access

To search the 'global.db' database of the EmpyrionSavegame and to add own queries to the configuration you can use the SQLiteBrowser https://sqlitebrowser.org/.

By default the following parameters are available for the query:

The following queries are available:

Entities

SELECT * FROM Structures 
JOIN Entities ON Structures.entityid = Entities.entityid
JOIN Playfields ON Entities.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId)) {additionalWhereAnd}

DiscoveredPOIs

SELECT * FROM DiscoveredPOIs
JOIN Entities ON DiscoveredPOIs.poiid = Entities.entityid
JOIN Playfields ON Entities.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (Entities.isremoved = 0 AND (DiscoveredPOIs.facgroup = 0 OR DiscoveredPOIs.facgroup = 1) AND (DiscoveredPOIs.facid = @PlayerId OR DiscoveredPOIs.facid = @FactionId)) {additionalWhereAnd}

TerrainPlaceables

SELECT * FROM TerrainPlaceables 
JOIN Entities ON TerrainPlaceables.entityid = Entities.entityid
JOIN Playfields ON TerrainPlaceables.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId OR TerrainPlaceables.entityid = @PlayerId OR TerrainPlaceables.entityid = @FactionId)) {additionalWhereAnd}

TerrainPlaceablesRes

SELECT * FROM TerrainPlaceables
JOIN PlayfieldResources ON (PlayfieldResources.pfid = TerrainPlaceables.pfid AND abs(PlayfieldResources.blockx - TerrainPlaceables.blockx) <= 20 AND abs(TerrainPlaceables.blockz - PlayfieldResources.blockz) <= 20)
JOIN Entities ON TerrainPlaceables.entityid = Entities.entityid
JOIN Playfields ON TerrainPlaceables.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE (isremoved = 0 AND (facgroup = 0 OR facgroup = 1) AND (facid = @PlayerId OR facid = @FactionId OR TerrainPlaceables.entityid = @PlayerId OR TerrainPlaceables.entityid = @FactionId)) {additionalWhereAnd}

Playfields

SELECT * FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE playfields.ssid IN (
SELECT ssid FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
WHERE (DiscoveredPlayfields.facgroup = 0 OR DiscoveredPlayfields.facgroup = 1) AND (DiscoveredPlayfields.facid = @PlayerId OR DiscoveredPlayfields.facid = @FactionId)
GROUP BY playfields.ssid
) {additionalWhereAnd}

PlayfieldResources

SELECT * FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
JOIN PlayfieldResources ON PlayfieldResources.pfid = Playfields.pfid
WHERE playfields.ssid IN (
SELECT ssid FROM Playfields
LEFT JOIN DiscoveredPlayfields ON DiscoveredPlayfields.pfid = playfields.pfid
WHERE (DiscoveredPlayfields.facgroup = 0 OR DiscoveredPlayfields.facgroup = 1) AND (DiscoveredPlayfields.facid = @PlayerId OR DiscoveredPlayfields.facid = @FactionId)
GROUP BY playfields.ssid
) {additionalWhereAnd}

PlayerData

SELECT * FROM PlayerData 
JOIN Entities ON Entities.entityid = PlayerData.entityid
JOIN Playfields ON Playfields.pfid = PlayerData.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE ((Entities.facgroup = 0 OR Entities.facgroup = 1 OR facgroup = 0 OR facgroup = 1) AND (Entities.facid = @PlayerId OR facid = @PlayerId OR Entities.facid = @FactionId OR facid = @FactionId)) {additionalWhereAnd}

Bookmarks

SELECT * FROM Bookmarks
JOIN Entities ON Bookmarks.entityid = Entities.entityid
JOIN Playfields ON Bookmarks.pfid = Playfields.pfid
JOIN SolarSystems ON SolarSystems.ssid = Playfields.ssid
WHERE ((Bookmarks.facgroup = 0 OR Bookmarks.facgroup = 1) AND (Bookmarks.facid = @PlayerId OR Bookmarks.facid = @FactionId)) {additionalWhereAnd}

External data

Here with it is possible to retrieve external data from the AddOnAssemblys. Which parameters are additionally required must be taken from the documentation of the respective external data source.

Providing a DLL for the external data (with an example from the EmpyrionGalaxyNavtigator).

This Dll must have a class which implements the IMod interface. Also, the must implement a property 'ScriptExternalDataAccess'.

public class ExternalDataAccess : IMod
{
    public IDictionary<string, Func<IEntity, object[], object>> ScriptExternalDataAccess { get; }

    public ExternalDataAccess()
    {
        ScriptExternalDataAccess = new Dictionary<string, Func<IEntity, object[], object>>()
        {
            ["Navigation"] = (entity, args) => entity?.Structure?.Pilot?.Id > 0 ?         Navigation(entity) : null,
            ["MaxWarp" ]   = (entity, args) => entity?.Structure?.Pilot?.Id > 0 ? (object)MaxWarp   (entity) : null,
        };
    }

Furthermore the path to the DLL must be specified in the configuration file of the EmpyrionScripting. (Basis is the mod directory of the EmpyrionScripting in the savegame).

"AddOnAssemblies": [
    "..\\EmpyrionGalaxyNavigator\\EmpyrionGalaxyNavigatorDataAccess.dll"
],

And the DLL must be copied to its intended place (in the case of EmyprionGalaxyNavigator in its mod directory in the savegame) The DLL can be found in this file 'EmpyrionGalaxyNavigatorDataAccess.zip' which is included in the ModLoaderpaket or can be downloaded from https://github.com/GitHub-TC/EmpyrionGalaxyNavigator/releases.

When the functions are called, the current entity and the passed 'args' are also passed. (in this case no further parameters are needed to access the GalaxyNavigator).

{{#external 'MaxWarp'}}
Maximum jump range: {{.}}
{{/external}}

Elevated scripts (Savegame or Adm structures)

SaveGame scripts

This special form of scripts can be stored in the SaveGame. The basic path for this is the [Savegame]\Mods\EmpyrionScripting\Scripts

This path is avaiable with @root.MainScriptPath

in this directory script files with the extension *.hbs are searched for according to the following pattern

Note: EntityType is BA,CV,SV or HV

CustomHelpers-SaveGameScripts (readfile)

CustomHelpers-SaveGameScripts (writefile)

CustomHelpers-SaveGameScripts (fileexists)

Prioritization of scripts

If many scripts are built in it makes sense to downgrade the ones that don't need to be executed so often, so that the other scripts are executed more often. To do this, you can write a number from 0-9 BEFORE the name of a script, so that this script is executed only every N cycles. e.g. 1Script:abc 3Script:uvw 4Script:xyz

1: abc 2: abc 3: abc, uvw 4: abc, xyz 5: abc 6: abc, uvw 7: abc 8: abc, xyz ...

The difference between a script WITHOUT a number or 0 and a script with a '1' is that scripts with a priority with a priority >= 1 will run regardless if the ScriptLCD is switched off.

Scripts with 0 or no number will only be executed if the LCD is on. (Note: you can set the font color (for projectors) to transparent to make it "invisible")

Automatic Amount Adjustments

For Fuel, O2,... it can be useful to use the current values from the Ecf configuration (of the scenario) The “EcfAmountTag” entry can be specified for this purpose. The value for “Amount” is then automatically determined from the item with the value of the tag. If the value is not to be determined automatically, “EcfAmountTag:”” can be specified.

Examples of automatic determination

{
    “ItemName": ‘EnergyCellLarge’,
    “Amount": 250,
    “EcfAmountTag": ”FuelValue”
}
...
{
  “ItemName": ‘OxygenBottleLarge’,
  “Amount": 250,
  “EcfAmountTag": ”O2Value”
}

no automatic determination

{
    “ItemName": ‘EnergyCellLarge’,
    “Amount": 250,
    “EcfAmountTag": ””
}

General

If the structure is turned off or has no power, no ingame scripts will be executed from it. So "old" or no longer used structures do not consume any power of the script engine.

Set execution and performance of the scripts

Hint: ...\Saves\Games[Savegamename]\Mods\EmpyrionScripting\Configuration.json

"SaveGameScriptsIntervallMS": 10000,
"ScriptsSyncExecution": 2,
"ScriptsParallelExecution": 4,
...
"ProcessMaxBlocksPerCycle": 200,

Are set VERY conservatively by default so as not to put the server (and the game) under load. Double the values (SaveGameScriptsIntervallMS must lower) and the scripts will run more "smoothly", but there may be micro-jerks in the game.

Whats next?

ASTIC/TC