[mod] Empyrion Scripting Mod

Discussion in 'Empyrion API' started by ASTIC, May 25, 2019.

Tags:
  1. Harlekin_7

    Harlekin_7 Ensign

    Joined:
    Sep 12, 2017
    Messages:
    3
    Likes Received:
    0
    Dazu direkt noch eine Nachfrage von mir, funktioniert das mit dem Cargo Teleporter auch nur via SaveGameScript oder sollte das auch so möglich sein ?
     
    #181
  2. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Zu 1: vermutlich sind die Strukturen nicht auf der selben Fraktion - das Script habe ich mit der 1.2 ausprobiert und es funktioniert noch
    Zu 2: Schau mal im Savegame nach was in der "dedicated.yaml" steht oder direkt in Saves - das sind Fallbacks wenn die Mod den Namen des Savegames nicht ermitteln kann. Im SP hat das Spiel leider eine Macke und liefert als Namen des Savegames nicht den aktuellen sondern einen vorher geladenen, daher im SP immer das Spiel neu starten und dann das Savegame auswählen mit dem man spielen möchte
     
    #182
  3. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
  4. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Zu 1: Ja das war die Ursache :oops: Ich habe kurz vor dem Update mit den Fraktionen rumgespielt...

    Zu 2: Ich habe alle json und yaml sowohl auf dem client wie auf dem server angeschaut, ich finde einfach nichts.
    Kann ich die config nicht irgendwo runterladen?

    Das mod funktioniert ja, es legt auch in einem neuen singleplayer save die ordner "D:\SteamLibrary\steamapps\common\Empyrion - Galactic Survival\Saves\Games\NeuesSpiel_0\Mods\EmpyrionScripting\Scripts" und "D:\SteamLibrary\steamapps\common\Empyrion - Galactic Survival\Saves\Games\NeuesSpiel\Mods\EmpyrionScripting\Scripts" an aber die sind leer.


    Zu neuer Version: Yay, PowerConsumption.
    Ich fahre gleich den Server runter und installiere die Version.

    Aber ob das meinem Fuel Script hilft weis ich noch nicht weil Ich annehme das ich immer noch nicht rausfinden kann ob es auf solar oder generator läuft... Jetzt fehlt nurnoch SolarPower und SolarCapCharge.
     
    #184
  5. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    lol ... du hoffst doch nicht ernsthaft das sie an Solar und die anderen Dinge gedacht haben ;-)
    in der 5.10.9 werden die Configdateien nun erzeugt wenn sie nicht existieren
     
    #185
  6. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Naja, ich hoffe das sie noch weiter machen Power Sachen zugänglich zu machen, am besten per device mit ein/aus/inhalt und das möglichst komplett für alles (was energie verbraucht/erzeugt/lagert)

    Und die Config ist jetzt da. (Ich war echt schon am zweifeln was ich falsch mache)

    Vielen lieben Dank :);)
     
    #186
    ASTIC likes this.
  7. dmuser

    dmuser Ensign

    Joined:
    Oct 24, 2020
    Messages:
    1
    Likes Received:
    0
    I am having issues with the Sorter script. All it returns to SorterDB is
    {{devicesoftype}} error Object reference not set to an instance of an object​

    Meanwhile the Containers script that lists what is present in all connected containers by lcd with DSP-* uses the same {{devicesoftype}} switch and seemingly has no issues. Have I missed a variable somewhere?

    Thanks in advance.
     
    #187
  8. dping28

    dping28 Ensign

    Joined:
    Sep 20, 2020
    Messages:
    4
    Likes Received:
    0
    Love this mod! Need a little help - havent quite got this 'language' down yet. I have been using the recycle script from the scripting demo but am running into a case where the box I assign to it constantly shows "Currently occupied" after trying to run it and I cant clear that without logging out of the game. Is there a way to stop that from happening? Also is there a way to modify the script to use multiple boxes if one fills up? Salvage1,Salvage2,etc - THANKS!
     
    #188
  9. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Code:
    {math} [-132387,6]:Error in System.Object:(wrapper dynamic-method) object:lambda_method (System.Runtime.CompilerServices.Closure,System.IO.TextWriter,object) Invalid instruction 39 18:12:22
    anny idea what that could be?
    the code is a savegame script:
    Code:
    {{#use E.S.FuelTank}} -Fuel-
    {{~set 'con' Content}}
    {{~set 'cap' Capacity}}
    {{/use}}
    PowerConsumption:
    {{E.S.PowerConsumption}}
    {{~math @root.Data.con '/' @root.Data.cap }}
    {{#test . le 0,25}}
    <color=red>
    {{else}}
    {{#test . le 0,5}}
    <color=blue>
    {{else}}
    <color=green>
    {{/test}}
    {{/test}}
    {{/math}}
    {{bar @root.Data.con 0 @root.Data.cap 20 }}
    </color>
    {{math @root.Data.con '/' @root.Data.cap}}{{~format . '{0,8:P2}'}}{{~/math}} = {{~format @root.Data.con '{0,7:0.0}'}} / {{format @root.Data.cap '{0,7:0.0}'}}
    {{math @root.CacheData.fuel '-' @root.Data.con }}
    {{~#test . neq 0}}
    {{~set 'secleft' (calc @root.Data.con '/' . )}}
    {{~set 'restt' (calc  @root.Data.secleft '%' 8640 )}}
    {{~set 't' (calc (calc  @root.Data.secleft '-' @root.Data.restt ) '/' 8640)}}
    {{~set 'resth' (calc  @root.Data.restt '%' 360 )}}
    {{~set 'h' (calc (calc  @root.Data.restt '-' @root.Data.resth ) '/' 360)}}
    {{~set 'restm' (calc  @root.Data.resth '%' 6 )}}
    {{~set 'm' (calc (calc  @root.Data.resth '-' @root.Data.restm ) '/' 6)}}
    {{~setcache 'output' (concat @root.Data.t 'Tage ' @root.Data.h 'Std ' @root.Data.m 'Min')}}
    {{~setcache 'fuel' @root.Data.con}}
    {{~else}}
    {{~setcache 'output' "kein Verbrauch"}}
    {{~/test}}
    {{~/math}}
    {{@root.CacheData.output}}
     
    #189
  10. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    I haven't tried it live yet, but in line 21, @root.CacheData.fuel is an undefined object on the first run. You probably have to query this via {{#ok @root.CacheData.fuel}}calc{{else}}init{{#ok}} and initialize it on the first run.
     
    #190
  11. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Yes, seems it was that one variable; 'did the #OK thing bevore all the math with the else initializing it, now the error did not show.
    How can I interpret those error messages? It does not say the variable or line or annything i could decrypt...
     
    #191
  12. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    my autofill script is running amok:
    my script keeps putting my pentaxid somehrere...
    i have just enough volume missing in the tank of one cv that it showns 1 pentaxid missing, while i cant put one in, says not enough space.
    no proof where the script puts the pentaxid, but that almot full tank seems to be it.

    The script is a bit a hack as i run it in a base to refuel both cv and the small vesels on them. but it used to work just fine until i discovered my pentaxid was gone...

    Code:
    <align=center><i><size=10>Autofill docked vessels</size></i></align><size=8>
    {{~set 'IDs' '2373,2294,2128'}}
    {{~setblock 'b1'}}
    {{~#getswitch @root.E.S 'S_AutoFuel'}}{{#if SwitchState}}
    {{~#entitiesbyname '*' 200}}
    {{~#each .}}
    {{~set 'str' . }}
    {{Name}}
    {{~#items @root.E.S 'AutoFuel*'}}
    {{~#math (configattr Id 'StackSize') '/' 10}}
    {{~set 'Stacks' (int (max 10 .))}}
    {{~/math}}
    {{~#test Count ge @root.Data.Stacks}}
    {{~#test Id in @root.Data.IDs}}
    {{~#fill ../this @root.Data.str/S 'Oxygen' 100}}{{/fill}}
    {{~#fill ../this @root.Data.str/S 'Fuel' 100}}{{/fill}}
    {{~#fill ../this @root.Data.str/S 'Pentaxid' 100}}{{/fill}}
    {{~/test}}{{/test}}{{/items}}{{/test}}{{/each}}{{/entitiesbyname}}
     
     
     
     
    {{~else}}
     
     
    <align=center><color=red>Switch this lever to automaticly
    fuel up your docked vessels.</color></align>
    {{/if}}{{/getswitch}}
     
     
     
     
     
     
     
     
     
     
     
    {{/setblock}}
    {{scroll 12 2}}
    {{selectlines 1 0 9}}
    {{@root.Data.b1}}
    {{/selectlines}}
    {{/scroll}}
     
     
     
    </size><size=6>
    {{#getitems @root.E.S 'AutoFuel*'}}
    {{~#itemlist . @root.Data.IDs}}
    {{~#math (configattr Id 'StackSize') '/' 10}}
    {{~set 'Stacks' (int (max 10 .))}}
    {{~/math}}
    {{#test count le @root.Data.Stacks}}
    <indent=6>◉ <color=red>Not Enough: <color=#00cccc>{{Name}}{{Id}}</color> (<color=orange>{{Count}}</color>)</color></indent>
    {{else}}
    <indent=6>◉ <color=green>Plenty:</color> <color=#00cccc>{{Name}}{{Id}}</color> (<color=orange>{{Count}}</color>)</indent>
    {{/test}}
    {{/itemlist}}
    {{/getitems}}
    </size>
    i'm not sure how the fill works exactly, so anny help how i could fix it would be great.
     
    #192
  13. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Sorry.... got yet another problem:

    can the cargo teleporter script cause the playfield server to crash?
    i have a home-server and run reforged eden.

    i sent like 3 cargocontainers worth of stuff, (about 30 stacks, some just random items, some 4 stacks of ore) to a base and teleportet there;
    after some seconds the CargoInInfo lcd showed the stuff ariving and the playfield server crashed/kicked me. could not rejoin right away, got that error screen saying the playfieldserver had a problem and all players were kicked, try again in a few minutes. as i could reconnect the playfield was in state bevore the teleport (all stuff lost between the teleporters)

    is there something i can do to prevent this?
     
    #193
  14. Slavens

    Slavens Lieutenant

    Joined:
    Jun 26, 2016
    Messages:
    10
    Likes Received:
    3
    I have a quick question. I dug through the thread and didn't see the answer - maybe because my German sucks, but that's my fault. ;)

    I modified the Ammo Counter script over on the scripts thread for use in a CV.
    https://empyriononline.com/threads/mod-ext-empyrion-scripting-scripts.92458/#post-390302

    I think I did it right. Essentially I changed line 2, which seems to be the weapons/ammo data.

    I want to test it, but I can't get it to run again. It's a three-part script where the initial script populates a second LCD that you edit to fill out your number of weapons, which in displays an ammo loadout screen.

    It worked the first time, but listed weapons for a BA (OFC). I replaced the second line for CV weapons & ammo, but I can't get the script to regenerate the second screen (WeaponConfig).

    How do I get the first part to run again to regenerate the second screen?
    Or is it just failing because I fubared it?

    This is my replacement line 2. It's the only thing I changed:
    Code:
    {{~set 'F' '769,2215;287,2104;1145,2201;288,2206;567,2102;646,2206;1142,2205;702,2210;'}}
    
    I still need to add a couple weapons to it.

    Never mind. I figured it out. I had to remove the existing text in the WeaponConfig LCD
     
    #194
    Last edited: Nov 23, 2020
  15. Amenophis

    Amenophis Ensign

    Joined:
    Jul 16, 2018
    Messages:
    7
    Likes Received:
    0
    Thank you for this mod!

    Sorry for my english but i have a question about Playfield data. It's possible to know the terrain height at a specific position? I see "GetTerrainHeightAt" in the source but i dont know how use it. (I've tested many things but not the good thing. Maybe is not possible? ). I want put an alert to the screen if the vessel is under a certain height to remind to retract weapons under vessel before a landing ^^

    upload_2020-12-11_23-31-57.png


    EDIT: Ok! I've found! We must use #C savegames scripts to access objects methods.
     
    #195
    Last edited: Dec 12, 2020
  16. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    #196
    Homunk and Thodin O Gondrafn like this.
  17. Peter L

    Peter L Ensign

    Joined:
    Jan 19, 2017
    Messages:
    2
    Likes Received:
    0
    I am wanting to use the below script to transfer items from one box to a few others,
    ore to one, fuel to another, items to another etc...
    how do I moddify the code?

    {{#each E.S.DockedE}}
    {{#items S 'Box*'}}
    {{move . @root.E.S 'BoxA'}}
    {{SourceE.Name}}:{{Source}}->
    {{~DestinationE.Name}}:{{Destination}}
    {{format Count '{0,5}'}} : {{i18n Id 'Deutsch'}}
    {{/move}}
    {{/items}}
    {{/each}}


    ---------------------------------------------

    {{fontsize 4}}
    {{#items E.S 'BoxA'}}
    {{#test Id leq 1000}}
    {{move this @root.E.S 'BoxB' 100}}
    {{SourceE.Name}}:{{Source}}->
    {{~DestinationE.Name}}:{{Destination}}
    {{format Count '{0,5}'}} : {{i18n Id 'Deutsch'}}
    {{/move}}
    {{else}}
    {{move this @root.E.S 'BoxB'}}
    {{SourceE.Name}}:{{Source}}->
    {{~DestinationE.Name}}:{{Destination}}
    {{format Count '{0,5}'}} : {{i18n Id 'Deutsch'}}
    {{/move}}
    {{/test}}
    {{/items}}
     
    #197
  18. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Des Handlebar zeugs geht mir auf die Nerven, und ich habe das Gefühl es ist langsam bei umfangreichen scripten, auch weil man umständlich vorgehen muss. (langes savegame script das auch zu lang für ein LCD währe)
    Deshalb möchte ich meine Scripte gerne generalisieren und als savegame scripte in c# neu schreiben. (und eventuell veröffentlichen)

    Dazu die Frage: was ist ein geeigneter Editor, gibt es eventuell sogar die Möglichkeit das der spezifische Syntax (sowas wie root.E.S) vorgeschlagen wird? (für die nativen Empyrion Mods gibts ja des visual studio solution dingens im beispiel mod)

    Vielen Dank
    PS: Oder währe ich besser dran gleich ein natives Mod zu schreiben?
     
    #198
  19. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Du kannst einfach mit VisualStudio(Express) ein .NET Framework Consoleanwendungsprojekt anlegen und dort die EmpyrionScripting.Interface.dll aus dem Modverzeichnis referenzieren (und was du noch für DLLs so brauchst). Dann kannst du einfach in einer CS Datei deine Mod schreiben und hast die Intellisenseunterstützung des Studios.

    Eine native Mod geht natürlich auch nur hast du dann mit den ganzen Unwägbarkeiten der API und des Spieles zu kämpfen.
    PS: Über die ModAPI hast aber auch von einem C# Savegame Script den vollen Zugriff auf alles
     
    #199
  20. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Cool Danke.
    Mal sehen wie eingerostet mein c# ist ;)

    noch Fragen zu Besonderheiten:

    -die Main Funktion wird ja immer neu aufgerufen (alle 10s default) an welchem Objekt im Spiel hängt die? Ich nehme an nicht unbedingt an einem LCD, die laufen soweit ich sehen kann auch ohne; also an jeder Entity? (das sind alle mit core, richtig?)
    -Wie kann ich Daten zwischen Aufrufen am besten zwischenspeichern (ich hab n DateTime) ich vermute mit root.Data aber bin nicht sicher wie das am besten gemacht wird. (normalerweise hat man ja ne schleife in der Main)
    -Und darf ich Blöcke aus dem CargoTeleporter als Vorlage nehmen?

    Danke nochmal :D
     
    #200

Share This Page