[MOD EXT] Empyrion Scripting - Scripts

Discussion in 'The Hangar Bay' started by Ephoie, Mar 22, 2020.

  1. Salt The Fries

    Salt The Fries Ensign

    Joined:
    Mar 29, 2021
    Messages:
    9
    Likes Received:
    5
    Huh... I detected the problem (And still it's still reproducible) with a CV for me...
    but the game is in Dedicated server with EmpyrionScripting running on the server-side.

    Maybe I could provide a more private/direct message to the server in question for additional debugging...
    Am willing to help! :)
     
    #461
  2. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    We have no issues on our server (9.2.2), but we did have issues going from v8 to v9. It was caused by the configuration.json file in the save directory of the server did not update when we updated the mod. This was fixed by deleting the configuration.json file which got recreated when the server restarted (and reloaded the mod)

    I think this was when we went from version 8 to version 9 where the configuration.json file changed from holding id's to holding names.

    Maybe ask the admin to check that file and see if it contains ids (from version 8 or before) to names (version 9 and on)

    The only issue we have now in 9.2.2. is some weapons names show incorrectly and most likely just missing from the WeaponCV part of the config file (Sentinal Flak) and still have not got Empyrion navigation mod working yet. Using Mod loader now but still no luck but most likely me setting it up wrong.

    If you want, I could spawn your ship on my server (New Zealand based) for testing?
     
    #462
    Last edited: May 11, 2022
  3. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    #463
    Last edited: Jun 7, 2022
  4. Salt The Fries

    Salt The Fries Ensign

    Joined:
    Mar 29, 2021
    Messages:
    9
    Likes Received:
    5
    @ASTIC I uploaded my test file to https://steamcommunity.com/sharedfiles/filedetails/?id=2806978100&searchtext=ES_DebugTest

    There's also a link to the server in question (if that helps... no idea if it does or not.)
    It's stripped-down minimal.. Maybe it would help if I could figure out additional information as to what's going on in there. Maybe if I build the source... hmm...

    Nathan - We tried deleting the config file as suggested, but it made no difference... The server is (was?) relatively new (Less than 10 days of operation). NZ is quite a long walk from AZ... I wonder what the differences in the server would be, but it would be some test-cases to put down and eliminate or confirm.
     
    #464
  5. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    I will spawn it when I get home, add some items to it and see what shows up. Will get back to you in 5hrs (when I am home)
     
    #465
  6. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    The API has access only to named cargo boxes:
    This not work ->
    upload_2022-5-12_7-9-46.png

    but this ->
    upload_2022-5-12_7-11-39.png
     
    #466
  7. Salt The Fries

    Salt The Fries Ensign

    Joined:
    Mar 29, 2021
    Messages:
    9
    Likes Received:
    5
    ... That... makes a lot of sense in hindsight... Sorry for all the trouble! And thanks for being so patient with me.
    And in case I didn't say it before, Thanks for making such an awesome mod that really exceeds all expectations.
     
    #467
    ASTIC likes this.
  8. Luke Benko

    Luke Benko Ensign

    Joined:
    Mar 30, 2021
    Messages:
    12
    Likes Received:
    3
    I think I fixed the Dynamic Sorting Code! Will need someone that is better at scripting than me to go through it. Original code by Shadowviper! Please give him all credit as all I did was update code.


    Name: Dynamic Transfer/Sorting System (By Shadowviper)
    Description: Takes items from an input crate and moves to the correct location. Placing an item into a crate logs its ID to a separate screen after which that item will always move to that location, even if it is no longer there. Any items not yet logged are moved to an "Unsorted" location to be manually moved the first time (only need to move 1 of at item and the rest will follow).

    Optionally has a variable for 'Constructor Input' which will move only 50 of each item found, and is able to pull from any storage not just Input/Unsorted

    Output logs time of transfer and what was moved and where.

    Example:
    • Place 900 Iron into crate 'Input'
    • 900 Iron moved to 'Unsorted'
    • Take 1 Iron and place in crate 'Ingots'
    • Iron ID logged to SorterDB screen
    • 899 Iron moved from 'Unsorted' to 'Ingots'
    • ---
    • Take 1 Iron and place in crate 'Constructor Input'
    • 49 Iron moved from 'Ingots' to 'Constructor Input'
    • ---
    • Remove remaining 850 Iron from 'Ingots' and discard. Ingots is now empty
    • Place 500 Iron into 'Input'
    • 500 Iron moved from Input to Ingots, remembering where it should go even though Ingots is now empty
    Respects Volume/Mass. If a crate is overflowing will check for any crates with the same name and a hypenated number afterwards, in order. In the above example if 'Ingots' was full the iron would try to move to 'Ingots-2', 'Ingots-3' and so on, otherwise it is retained in 'Input' and not moved

    Manually moving items is possible - only Input and Unsorted are used as a source so manually moving between crates A and B is possible and will not immediately try to move the item back. To reset, open the screen 'SorterDB' and wipe contents after placing all items in the correct place. All items will instantly repopulate with where they are currently in the DB and any future inputs go to the right place

    Crate names can be manually entered on line 2 of code

    Picture:
    Output log
    [​IMG]

    "SorterDB" being generated from placed items
    [​IMG]
    LCD Input Name: Script:[+30]Sorter, SorterDB
    LCD Output Name: Sorter
    LCD Dimensions: >=0.5x0.5
    LCD Input Script:
    Switch: sw_AS

    Extra Step: Add a switch with sw_AS as the signal.
    Switch on will sort, Switch off will shut it down. Other than that I think it works.

    Code:
    {{fontsize 2}}{{~set 'F' '1'}}{{#getswitch @root.E.S 'sw_AS'}}{{#if SwitchState}}
    {{~set 'I' 'Input'}}{{set 'CI' 'CInput'}}{{set 'O' 'Output'}}{{set 'U' 'TOBESORT'}}
    {{~devices @root.E.S 'SorterDB'}}{{set 'DB' .0}}{{gettext .0}}{{split . '\n'}}{{set 'C' .}}{{/split}}{{/gettext}}{{/devices}}
    {{~#devicesoftype @root.E.S 'Container'}}{{#each .}}{{if CustomName}}{{set 'T' ''}}{{set 'M' 0}}
    {{#split CustomName '-'}}{{set 'n' .}}{{/split}}
    {{~#test @root.data.n.0 in (concat @root.Data.I ',' @root.Data.O ',' @root.Data.U)}}
    {{~#items @root.E.S CustomName}}{{set 'G' @root.data.U}}
    {{#each @root.data.C}}{{#split . ':'}}{{~#test ../../Id in .1}}{{~#test @root.data.CI neq .0}}{{set 'G' .0}}{{/test}}{{/test}}{{/split}}{{/each}}
    {{~#test ../CustomName neq @root.Data.G}}
    {{~move this @root.E.S (concat @root.Data.G '*')}}{{set 'M' 1}}
    {{set 'T' (concat @root.data.T '
    ' ../Name ' - '  Count '<indent=55%>❲' Source ' ➤ ' Destination '❳</indent>')}}
    {{/move}}{{/test}}{{/items}}{{else}}{{set 'x' ''}}
    {{~#each @root.Data.C}}{{#split . ':'}}{{#test @root.data.n.0 eq .0}}{{set 'x' .1}}{{/test}}{{/split}}{{/each}}
    {{~items @root.E.S CustomName}}{{#test Id in @root.data.x}}{{else}}{{set 'x' (concat @root.data.x Id ',')}}{{/test}}
    {{~#test Id in @root.data.CID}}
    {{~move this @root.E.S (concat @root.Data.CI '*') 50}}{{set 'M' 1}}
    {{set 'T' (concat @root.data.T '
    ' ../Name ' - '  Count '<indent=55%>❲' Source ' ➤ ' Destination '❳</indent>')}}
    {{/move}}{{/test}}{{/test}}{{/items}}
    {{~#if @root.data.x}}{{#if @root.data.n.1}}{{else}}{{set 'D' (concat @root.data.D @root.data.n.0 ':' @root.data.x "
    ")}}{{/if}}{{/if}}{{#test @root.data.n.0 eq @root.data.CI}}{{set 'CID' @root.data.x}}{{/test}}{{/test}}
    {{#if @root.data.M}}
    <align=center><size=120%>Transfer - {{datetime 'HH:mm'}}</size></align>
    {{@root.data.T}}
    <align=center><size=4>{{bar 1 0 1 10 '╼╾'}}</size></align>
    {{/if}}{{/if}}{{/each}}{{/devicesoftype}}
    {{settext @root.Data.DB @root.Data.D}}{{/if}}{{/getswitch}}
    
     
    #468
    Last edited: May 12, 2022
    bigbubbajager and Kassonnade like this.
  9. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    Your edit Dynamic Sorting Code work, congrats.

    I was going to use hardcode locations myself and wanted to use the ID groups define in the configuration file to 'sort' stuff for me

    "Ore","Ingot","BlockL","BlockS","Medic","Food","Ingredient","Sprout","Tools","ArmorMod","DeviceL","DeviceS","WeaponPlayer","WeaponHV","WeaponSV","WeaponCV","WeaponBA","AmmoPlayer","AmmoHV","AmmoSV","AmmoCV","AmmoBa"

    But there are too many that do not fall in those groups and hard to work out what can be broken down by an decontructor and what is already 'bases level parts' (eg. steel plates) and ready to sort.

    I will give the new Dynamic Sorting Code another go. Thanks
     
    #469
  10. Luke Benko

    Luke Benko Ensign

    Joined:
    Mar 30, 2021
    Messages:
    12
    Likes Received:
    3
    Just make sure to get a full copy. I had issues coping the code the first couple times, when I copied the original code. All I added was {{if CustomName}} after the first {{each}} and put a close {{/if}} at the end just before the last {{each}} and put in a code for a switch. I noticed that the error was because of unnamed containers. This way it forces the script to only use named containers. Anywsays if you have any issues please let me know and I will take a look at it.
     
    #470
    bigbubbajager likes this.
  11. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    I am using a long script to auto move cargo around different boxes on my ship, so I use the code
    Code:
    {{set 'Output' 'Script:[+20]AutoMoveCV'}}
    {{set 'SourceScripts' 'AutoMoveCV1,AutoMoveCV2,AutoMoveCV3,AutoMoveCV4',AutoMoveCV5''}}
    
    {{split @root.Data.SourceScripts ","}}
        {{#each .}}
            {{~devices @root.E.S .}}
                {{setblock 'text'}}
                    {{@root.data.text}}
                    {{gettext ../0}}
                        {{#if .}}
                            {{.}}
                        {{/if}}
                    {{/gettext}}
                {{/setblock}}
            {{/devices}}
        {{/each}}
    {{/split}}
    
    {{~devices @root.E.S @root.data.Output}}
        {{settextblock .0}}
            {{@root.data.text}}
        {{/settextblock}}
    {{/devices}}
    
    This works well but it also copy the 'blank' area before and after the scripts so when the output of AutoMoveCV is to a log screen, I get blank lines.
    Any easy way to suppress blank lines on a log output?
     
    #471
    bigbubbajager likes this.
  12. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Use the ~ to "hide" the command lines in the output.
     
    #472
    bigbubbajager and Nathan Jurgens like this.
  13. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    The Decontruct function.
    Any chance of having it also empty all containers to the same target location before doing the decontruct?
    I tried adding the Move command within the loop but it appear the decontruct triggered first.


    Also trying to work out why the ActiveRadar.hbs and ActiveAntenna.hbs are not working as expected.

    ActiveAntenna.hbs is showing all entities including asteroids up to 20k even tho the code looks like it should only show 'BA,CV,SV,HV,EnemyDrone,TroopTransport,Proxy'

    ActiveRadar.hbs is only showing asteriods but only up to 5k even tho the code looks like it should be 50k {{#entitiesbyname '*' 50000 'Ast*'}}
     
    #473
    Last edited: May 16, 2022
  14. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Everything beyond the range from DSLDistancePlanet & DSLDistanceSpace (in gameoptiones.yaml) is only a "proxy" or not even exists
     
    #474
  15. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    Ok I will increase those two setting and play around with it and remove Proxy from the ActiveAntenna.hbs (or add it to ActiveRadar.hb)

    I see the scripts PlayfieldInfos.hbs and ServerInfos.hbs read files from the server. Are these files created automatically or something you added to your server?
     
    #475
    Last edited: May 16, 2022
  16. Nathan Jurgens

    Nathan Jurgens Lieutenant

    Joined:
    May 18, 2016
    Messages:
    52
    Likes Received:
    5
    Anyone got come basic code I can copy for listing one line per item for a fleet wide summary. I am not sure how to get the math function working.
    I thought sometime like below would work, but clearly I do doing the math wrong
    Code:
    {{#each @root.E.S.DockedE}}
    {{Items S '*'}}
    {{math @root.Data.Name '+' count}}{{~set Name .}}{{~/math}}
    {{/Items}}{{/each}}
    
     
    #476
  17. rbrtgrmn

    rbrtgrmn Ensign

    Joined:
    Sep 6, 2018
    Messages:
    1
    Likes Received:
    0
    Does anyone know if the mod is broken atm? all my scripts suddenly stopped. The info LCD is simply blank.
     
    #477
  18. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    At the moment everything works fine.
    Do you play in SP or MP?
    And have you test it with the Demo CV or the Vega AI?
     
    #478
  19. Luke Benko

    Luke Benko Ensign

    Joined:
    Mar 30, 2021
    Messages:
    12
    Likes Received:
    3
    I am noticing when ever I move an item that has multiple variants with a script, it changes the item to the base version of it. IE: Undelivered Cargo. This is mainly a reforged Eden issue as far as I can tell. The game uses one item ID for multiple items. Not sure if there is an easy fix other than making sure it tests to make sure it is not trying to move the item. Anyhow just thought I would bring this up to you.
     
    #479
  20. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    991
    Likes Received:
    707
    Yes, unfortunately you can't move/edit tokens via scripting
    The API2 of Eleon provides only that you can edit items with ID and number. But the tokens still use ammunition and durability which are lost during the operations.
    I have the already give the API functions to extend but Eleon just does not want.

    This is "only" the base token
    Code:
    { +Item Id: 1305, Name: Token
      Class: Token
    }
    ...
    { +Item Id: 3407, Name: Eden_TokenCargo8k, Ref: Token
      CustomIcon: CargoContainerSV
    }
    
    { +Item Id: 3408, Name: Eden_TokenCargo16k, Ref: Token
      CustomIcon: ScifiContainer1Small
    ...
    so i have to check for the ECF attribute "Class" --> i will think about this
     
    #480

Share This Page