[mod] Empyrion Scripting Mod

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

Tags:
  1. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    PS: With the "test" command you can filter the output
    {{#items E.S 'Hauptlager'}}
    {{#test id in '2290,2396')}}
    {{format Count '{0,5}'}} : {{i18n Id 'Deutsch'}}
    {{/test}}
    {{/items}}
     
    #21
  2. Ephoie

    Ephoie Captain

    Joined:
    Jan 27, 2018
    Messages:
    331
    Likes Received:
    517
    Can someone post their configs here?
    Even some examples? It would help those who are not so fluent in German, or as tech-savvy as others
     
    #22
  3. Proof_89

    Proof_89 Ensign

    Joined:
    Jun 26, 2019
    Messages:
    4
    Likes Received:
    3
    Is this still working for Alpha 12? I can't get mine working :(
     
    #23
  4. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    I am working on it in the next days i think there will be an A12 version with the possibility to wrote the scripts not only in handlebars syntax but as an alternative also in C#
     
    #24
  5. Proof_89

    Proof_89 Ensign

    Joined:
    Jun 26, 2019
    Messages:
    4
    Likes Received:
    3
    Thanks man.
     
    #25
    Ephoie likes this.
  6. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729

    Attached Files:

    • 1.png
      1.png
      File size:
      1.4 MB
      Views:
      315
    #26
  7. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    Looks good ASTIC. I've had a skim through the change log while I'm at work so haven't downloaded the new demo yet - is there anything you can do in the C# version that wasn't possible through the handlebars interface, and is the C# version going to be the primary version going forward (is new functionality going to be added only via C# or will it be handlebars and C# where possible?)

    I do have possible suggestions for things you could add in future versions after you so kindly added the lookup functionality, although none of these are essential:
    • Maths
      • round
      • ceiling
      • floor
      • range (each loop of numbers between min & max, with step)
    • Variables
      • Append to current variable instead of nesting concat
      • Add/subtract from variable instead of nesting calc
    • Logic
      • not-in
    • Items
      • expose volume, mass, stacksize from config
    • Devices
      • devicesoftype for weapons/turrets
      • allow comma separated types like when finding devices by name, for example 'Container,AmmoCntr,HarvestCntr'
    • General
      • Current shield level for #use (as opposed to the current amount of 'fuel' in the pentaxid tank)
    I did some rough pseudocode examples of how these could be used, but you of course probably have a much better idea of how you'd do them!

    Code:
    Maths
    //{{round data}}
    {{set 'start' '3.2'}}
    {{round @root.data.start}}{{.}}{{/round}}
    {{@root.data.start}} //3
    
    //{{floor data}}
    {{set 'start' '3.2'}}
    {{floor @root.data.start}}{{.}}{{/floor}}
    {{@root.data.start}} //3
    
    //{{ceil data}}
    {{set 'start' '3.2'}}
    {{ceil @root.data.start}}{{.}}{{/ceil}}
    {{@root.data.start}} //4
    
    Variables
    //{{append key data [separator]}}
    {{set 'SomeNumbers' '4,8,15,16,23'}}
    {{append 'SomeNumbers' '42' ','}}
    {{@root.data.SomeNumers}} //4,8,15,16,23,42
    
    //{{set+ key data}}
    {{set 'i' '5'}}
    {{set+ 'i' 3}}
    {{@root.Data.i}} //8
    
    //{{set- key data}}
    {{set 'i' '5'}}
    {{set- 'i' 1}}
    {{@root.Data.i}} //4
    
    LOGIC
    {{set 'Ids' '2295,2265'}}
    {{set 'ToCheck' '3000'}}
    {{#test @root.Data.ToCheck nin @root.Data.Ids}}
    //true
    {{/test}}
    
    ITEMS
    {{#items @root.E.S '2295'}}
    {{#each .}}
    
    Name: {{Name}} //Steel Plate
    Count: {{Count}} //999
    Volume of 1 of this item: {{ItemVolume}} //0.2
    Volume of all of this item: {{StackVolume}} //199.8
    Allowed per stack: {{MaxStackSize}} //999
    
    {{/each}}
    {{/items}}
    
    General
    {{#use E.S.HullShield}}
    {{Content}} //45
    {{Capacity}} //100
    {{/use}}
    
    I've generally found a way to work around most of these at least for what I needed, but thought i'd suggest them in case you are looking for ideas after your C# implementation of what I've been trying to achieve

    Thanks again for such a fun mod :)


    Edit: Haven't tried A12 yet, but thinking ahead another suggestion would be if we could get the values for current power output / consumption, so a script can show a warning when over 100% generator capacity and/or set non essential blocks to inactive
     
    #27
    Last edited: Apr 27, 2020
    Sephrajin and Ephoie like this.
  8. Ephoie

    Ephoie Captain

    Joined:
    Jan 27, 2018
    Messages:
    331
    Likes Received:
    517
    This will work for 11.5.8 still?
     
    #28
  9. yodarocks1

    yodarocks1 Ensign

    Joined:
    Dec 18, 2018
    Messages:
    4
    Likes Received:
    0
    Question: Using a C# script, how can I pull a list of all entities (HV, SV, and CV, preferably not BA, though that would still be fine) within a certain distance or on the same playfield?
     
    #29
  10. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    I have not tried it, but I do not suspect that it worked because the ModAPI.dll has changed with the A12

    With CsRoot.EntitiesByName(string) you can get the Entities (that are active - no proxy -) within a MaxRange (in an admin structure all active on the playfield)
     
    #30
    Ephoie likes this.
  11. Raven_Ta2

    Raven_Ta2 Ensign

    Joined:
    Jan 22, 2020
    Messages:
    24
    Likes Received:
    17
    EmpyrionScripting stops working upon changing playfields. Is there a console command or any way to 'reboot' the script?
     
    #31
  12. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    There is a 30s delay after a playfield change for the restart.
    Im working on multiple auto restart procedures if something goes wrong -> comming soon
     
    #32
  13. Raven_Ta2

    Raven_Ta2 Ensign

    Joined:
    Jan 22, 2020
    Messages:
    24
    Likes Received:
    17
    No worries then, just wondered if you were aware of the problem. It doesn't restart even after spending hours in the same playfield with Alpha 12 experimental. Thanks for looking into it.
     
    #33
  14. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    On the latest Alpha all the spaces on my script screens have started showing squares . As its happening on all 4 scripts I assume its the script mod itself . I have Ship Stats,Active Antenna, Active Radar and Ship Status . Script mod version 5.5.20 .
     
    #34
  15. Myrmidon

    Myrmidon Rear Admiral

    Joined:
    Mar 26, 2016
    Messages:
    1,734
    Likes Received:
    2,066
    Also the console gets tons of red messages one after the other non stop. That is when loading a vessel with scripted LCD i.e. the LCD demo CV.
     
    #35
  16. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    #36
    Myrmidon likes this.
  17. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    Awesome stuff @ASTIC works great . I fear it has also done in your ActiveAntenna script . I had started a new game for the latest Alpha andforgot to load the script so didnt notice it sorry .
     
    #37
  18. johnietoth1967

    johnietoth1967 Commander

    Joined:
    Jun 15, 2020
    Messages:
    100
    Likes Received:
    91
    stupid question but in co-op will this work? if so how? Does the pc running the server have to install this only or does everyone playing have to have it installed?
     
    #38
  19. Preston

    Preston Commander

    Joined:
    Jul 6, 2017
    Messages:
    124
    Likes Received:
    25
    Great work ASTIC :)

    I have a question:
    I want to read in the text of a lcd device in C# mode like it's possible in handlebar.
    Do I miss something or does the "Text" interface in the C# device class not exist up to now?
    I could not find any hint on GitHub and I tried different spellings with no success.
     
    #39
  20. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,074
    Likes Received:
    729
    Code:
    var b = CsRoot.GetDevices<ILcd>(
    CsRoot.Devices(E.S, "Dummy"))
    .FirstOrDefault();
    
    if(b.GetText().StartsWith("W"))
    Console.WriteLine(
    $"<b>Wohoooo {b.GetText()}</b>");
    else
    Console.Write(b.GetText());
    But you need to allow: [EGS]\Saves\Games\[SaveGame]\Mods\EmpyrionScripting\CsCompilerConfiguration.json

    Code:
    "SymbolPermissions": {
        "Player": [
          "Eleon.Modding.ILcd.*",
        ],
    i will add this in the next version to the default.
     
    #40

Share This Page