[MOD EXT] Empyrion Scripting - Scripts

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

  1. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    No worries - I end up copying all sorts of weird and wonderful bugs by the time I actually get around to posting anything - or in some cases the wrong script entirely where i've ended up with multiple versions.

    You may want to have a look at the snippit I put a few posts above for keeping {fill} / {move} test displayed on screen for a few seconds - I actually tested it with your cargo mover script to save digging any of my old, untested in A12, ones out. So where you had the source/destination/item/count displaying it actually keeps it on screen for ~10 seconds rather than it just flashing up and disappearing. Does mean you need a 2nd screen to keep a backup copy of what was displayed, but that's not usually an issue in a size 30 CV :D
     
    #61
    Sephrajin likes this.
  2. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Based on this, I thought, well, we have all those 'Stash' backup LCD's, why not use that data and write a script to collect these.

    ALL CODE YOU SEE HERE IS : Work In Progress !!

    LCDs:
    • Script:Move_Output
    • Move_Output

    Code:
    <pos=0>◜</pos><pos=376>◝</pos>
    <align=center><i><size=150%>Cargo Transfer</size></i>
    </align><pos=0>◟</pos><pos=376>◞</pos>
    <color=grey>{{scroll 17 1}}
    <size=7>
    {{~devices @root.E.S 'Stash_*'}}{{#each .}}
    {{~gettext .}}
    <size=7><mspace=0.65em>{{.}}</mspace></size>
    {{~/gettext}}
    {{/each}}
    {{~/devices}}
    </size>
    {{/scroll}}
    </color>
    
    The size and mspace tags are to 'format' the output of the stash lcds, as I prepared a 'table'isque' appearance for the data.
    Allthough I did start with your code, hardly anything of that is left as changed the script to [+30] for which I had to remove the cycle and then figured that the device bugs around with the code I had at that state.

    Now it looks like:
    20200703154031_1.jpg
    Looks ready to to adjust the other move scripts for implenentation ;)

    LCDs:
    • Script:[+30]Stash_AutoMove
    • Stash_AutoMove

    Code:
    {{#getswitch @root.E.S 'sw_AutoMove'}}
    {{#if SwitchState}}
    {{~#each @root.E.S.DockedE}}
    {{#items S 'Loot*'}}
    {{~set 'Itemname' Name}}{{move this @root.E.S 'Drop Box'}}<size=7> {{datetime 'hh:mm:ss'}} |  Load  | {{format Count '{0,6}'}} | {{~format @root.data.Itemname '{0,27}'}} | <color=green>❰</color> {{SourceE.Name}}</size>{{/move}}
    {{/items}}
    {{/each}}
    {{/if}}
    {{/getswitch}}
    However, the one for refilling sometimes bugs around by having multiple empty lines - when then break formatting.

    LCDs:
    • Script:[+30]Stash_AutoFill
    • Stash_AutoFill
    Code:
    {{#getswitch @root.E.S 'sw_AutoFill'}}
    {{#if SwitchState}}
    {{~set 'LimitToType' 'SV,HV'}}
    {{~#each @root.E.S.DockedE}}
    {{~set 'Ship' Name}}{{#test EntityType in @root.Data.LimitToType}}
    {{#items @root.E.S 'Output Power'}}
    {{~set 'Itemname' Name}}
    {{#test id in 2373,2294,2128}}
    {{#test Count ge 1000}}
    {{#fill ../this ../../../S 'Oxygen' 100}}
     {{datetime 'hh:mm:ss'}} | Refill | {{format Count '{0,6}'}} | {{~format @root.data.Itemname '{0,27}'}} | <color=red>❱</color> {{@root.data.Ship}}
    {{/fill}}
    {{#fill ../this ../../../S 'Fuel' 100}}
     {{datetime 'hh:mm:ss'}} | Refill | {{format Count '{0,6}'}} | {{~format @root.data.Itemname '{0,27}'}} | <color=red>❱</color> {{@root.data.Ship}}
    {{/fill}}
    {{#fill ../this ../../../S 'Pentaxid' 100}}
     {{datetime 'hh:mm:ss'}} | Refill | {{format Count '{0,6}'}} | {{~format @root.data.Itemname '{0,27}'}} | <color=red>❱</color> {{@root.data.Ship}}
    {{/fill}}
    {{/test}}
    {{/test}}
    {{/items}}
    {{/test}}
    {{/each}}
    {{/if}}
    {{/getswitch}}
    
    Definitly needs some more work
     
    #62
    Last edited: Jul 3, 2020
    tachyon and shadowiviper like this.
  3. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    Very interesting concept, I hadn't thought of doing it that way but it does solve the problem of move-type scripts being a "log only", where you've got the Script:[+30] limits you on the formatting you can have around it without it constantly repeating itself, but doing it this way you can output your 'logs' and pull them into a section of a screen with formatting (e.g. your Cargo Transfer title). I may have to steal this idea :)
     
    #63
    Sephrajin likes this.
  4. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Dont be too eager, there's a catch - I'm currently writing a workaround -> count printed lines on an extra LCD and read its value and clean the Stash lcd if the value is too high -> so I can limit the catched text.

    EDIT:
    Got this counter to get started- Increases (and print) the counter by 1 till it hits 3, then clean output lcd and reset counter to 0.
    Move_AF_Index is the LCD that stores the counter-value.
    Code:
    {{~devices @root.E.S 'Move_AF_Index'}}{{#each .}}
    {{~gettext .}}
    {{~set 'CountAutoFill' .}}
    {{~/gettext}}
    {{/each}}
    {{~/devices}}
    {{#test 3 eq @root.data.CountAutoFill}}
    {{~set 'CountAutoFill' 0 }}
    {{devices @root.E.S 'Move_AutoFill'}}
    {{settextblock .0~}}
    {{/settextblock}}
    {{/devices}}
    {{else}}
     {{~set 'CountAutoFill' (calc @root.data.CountAutoFill '+' 1 )}}
    {{/test}}
    
    
    {{devices @root.E.S 'Move_AF_Index'}}
    {{settextblock .0~}}
    {{@root.data.CountAutoFill}}
    {{/settextblock}}
    {{/devices}}
    {{/test}}
    {{@root.data.CountAutoFill}}
     
    #64
    Last edited: Jul 3, 2020
  5. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    Whats the reasoning behind needing to limit the number of lines in the cached screen? Is it just to prevent one of them (move vs fill) from overrunning the other when displaying them both together?

    You might be able to do something similar by just changing the [+30] in the move/fill script name to "+3", so it would only ever output 3 lines of text and on the 4th line the first one output would drop off the bottom - as you're then reading the contents to merge in your table you wouldnt need the stash screens either, just read directly from the output of the move/fill.

    So some very high level pseudo code would be:

    Code:
    Script:[+3]AutoMove
    Last 3 items moved show a line on "AutoMove"
    Script:[+3]AutoFill
    Last 3 refuelsshow a line on "AutoFill"
    
    Script:MoveOutput
    Reads the only 3 lines shown on AutoMove
    Reads the only 3 lines shown on AutoFill
    
    Merge content of both screens together and display as a table
    
    Your table already has a scroll on it, so would show up to 17 rows and scroll through any more than that. The weird point with doing it this way is you'd always get the last 3 "moves" and last 3 "fills", even if you hadn't done a fill in days and have had 100 moves, you'd always get the last 3 of each as 1 table. Alternaively you could merge both scripts as they are controlled by separate switches, and just read from the single output so you'd get the last 6 'events' no matter what they were
     
    #65
    Sephrajin likes this.
  6. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    I'd like to use yet another LCD to 'sort' all the data by date, before actualy displaying it with the title.
    I finaly understand these [+N] .. so simple - yet effective... lol.. and I caused myself a headache over this :eek:o_O:rolleyes:

    EDIT:
    Is there even a sort mechanic? xD
    Havent checked yet...
    (just saying out loud, not asking)
     
    #66
  7. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    Version 5.6.0 - Preset&Custom ID lists
    upload_2020-7-8_18-32-47.png
    upload_2020-7-8_18-33-16.png

    pre-assigned, changeable and expandable via the config file [EGS]\Saves\Games\[SaveGame]\Mods\EmpyrionScripting\Configuration.json
    upload_2020-7-8_18-33-56.png

    Thanks to Sephrajin for the lists :)

    Have fun and greetings
    ASTIC
     
    #67
    tachyon, shadowiviper and Sephrajin like this.
  8. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    I just wonder how to manage the 15mm bullets, as they're used in multiple types.
    Is it ok to just reuse that id (likewise for 30mm and projectiles) for multiple id lists, or should we define a 'ids.AmmoShared'?
     
    #68
  9. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    At a glance, it looks like the new Id lists are literally just a comma separated string of numbers, so there'd be nothing to say you can't have the same Id twice, or write anything you like in them: it's just a shortcut to output that list of numbers so instead of "test in '1,2,3,4,5' etc" you can use "test in Id.Ore" to have a consistent reference to those ids without rewriting it constantly.

    So if you were adding new lists you could add one for "Weapons" with all weapon types, followed by "SVWeapons" with a smaller subset of those Ids, then "15mmWeapons" repeating some of the SV ones + the CV/HV/BA that use 15mm ammo (or even go down to "SV15mmWeapons" - although at that point you only have a single ID so would be quicker to just write the ID itself depending on your usage)
     
    #69
  10. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    I did intent go for something in the likes of:
    * WeaponSV
    * WeaponsHV
    * WeaoponsBA
    * WeaponsCV
    * AmmoSV
    * AmmoHV
    * AmmoBA
    * AmmoCV
    * AmmoPlayer

    If you then want to check for all wepaons, it should be as simple as (Hopefully):
    Code:
    {{~#test in Ids.Weapons*}}
    But even if one has to write the different 'lists', it's still alot easier than actualy writing the ids, PLUS, you know "what" you're working with.
     
    #70
    ASTIC likes this.
  11. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    Definitely be a lot easier to see - my #1 problem with writing scripts is hitting the limit of 2,000 characters inside an LCD screen. Some of my bigger scripts I go down thw .hbs server side file which doesn't have any such limitation, but then means I can't use that script in MP unless it's added to the server, or publish ships to the workshop etc (not that I know why I bother with that as I've not yet made anything solid enough to publish in the Workshop)

    I'd be interested to see if your "Ids.Weapons*" actually works or not, as you're essentially accessing a key/variable with a wildcard which I wouldn't expect to work. Even if not, you'd still be able to use "(concat Ids.WeaponSV "," Ids.WeaponCV)" which is still a lot shorter than writing out all Ids by hand
     
    #71
  12. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    I had asked Eleon a long time ago to equip one of the "computer deco consoles" with a simple text field that can hold 100k characters and which then serves as a script console - has unfortunately not yet been implemented :-(
     
    #72
    3N3RGY, Sephrajin and shadowiviper like this.
  13. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    That would be great if they did, and save me so much headache!

    Ironically the screen itself actually can hold more than 2k characters if that content is created by a script, it's only the input interface that wipes it out. I did some testing a while back where LCD-A was a script using {{bar}} to output 10,000 characters into LCD-B, with a token character at the end. LCD-B actually shows all of the text, even when you open it to edit (after disconnecting the script screen), but on closing it then only saves the first 2,000. So the screen itself is capable of storing more and even displaying it in the editor, but something in the Close/save process of that editor has a limit on it that looks to be hard-coded.
     
    #73
    Sephrajin likes this.
  14. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    True, wildcard might confuse the.. compiler, engine...?...
    However, I would expect "{{~#test in Ids.AmmoSV,Ids.AmmoHV}}" to work. :(

    20200709205221_1.jpg
     
    #74
    Last edited: Jul 9, 2020
  15. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    {{~#test in (concat Ids.AmmoSV ',' Ids.AmmoHV)}}
     
    #75
    shadowiviper and Sephrajin like this.
  16. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Today seems a bad day for coding, for me at least...

    First I cant move items from a local (@root.E.S) to a specific box of a docked vessel, then using the destruct script does not return any materials...

    And now even copy-pasted-adjusted code wont work....
    20200709211104_1.jpg
     
    #76
    Last edited: Jul 9, 2020
  17. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    145
    I say this every day going to work....

    Quick 2 minute test - {{Ids...}} isn't universal, so once you're inside a loop needs to be "@root.Ids.Ore". In your output `list:` isn't showing anything on the items failing the 'IN', but shows fine before that.

    upload_2020-7-9_22-55-29.png
     
    #77
    Sephrajin likes this.
  18. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Made some changes: (eg: added Titanium Rod to ingots, because it is the melted product of the ore...
    Also changed BlockS and BlockL to BlocksS and BlocksL

    Code:
      "Ids": {
        "Ore": "2248,2249,2250,2251,2252,2253,2254,2269,2270,2284,2293,2297,2311,2314",
        "Ingot": "2271,2272,2273,2274,2275,2276,2277,2278,2279,2280,2281,2285,2294,2298,2312,2318",
        "Medic": "2355,2356,2375,2377,2382,2385,2359,2393,2416,2426-2428,2430,2435-2441",
        "Food": "2325,2349,2354,2361,2362,2372,2374,2376,2378,2394,2409,2410-2412,2415,2417,2419-2421,2423-2425,2429,2431,2433,2434,2442,",
        "Ingredient": "2350,2351,2357,2359,2363,3264,2368,2381,2383,2388,2391,2392,2395,2400,2403-2405,2407",
        "Sprout": "490,591,594,597,600,607,639,641,644,1167,1171,1175,1179,1367,1527,1531,1597,1601",
        "Tools": "399,569,588,652,711,964,1108-1110,1485,2050,2059,2067,2069,2070,2071,2079,2080,2087-2089,2301,2749,2750",
        "ArmorMod": "2648 -2650,2653,2669-2676",
        "BlocksL": "343,396,399,402,405,408,411,462,545,839,1075,1128,1129,1238,1239,1322,1386,1392,1395,1440,1443,1481,1549",
        "BlocksS": "380,393,493,836,837,974,976,1135,1389,1478,1626,1960",
        "DevicesL": "259,260,263,278,291,335,336,468,469,498,558,564,653,686,714,717,724,781,960,962,1002,1008,1016,1034,1035,1095,1111,1112,1132,1134,1136,1231,1257,1263,1278,1318,1370,1371,1372,1373,1377,1402,1436,1465,1466,1490,1494,1495,1500,1513,1571,1588,1627,1628,1682,1683,1689,1692,1706,1711,1808,1812,1813,1956,2032,2033,2034,420,457,772,778,835,934,1120,1253,1304,1321,1486,";
        "DevicesS": "272,279,418,419,422,423,456,470,471,536,546,547,548,558,653,694,695,696,697,698,1375,1380,1435,1437,1446,1500,1585,1591,1592,603,604,1107,1127,1130,1417,1447,1484,1575,1583,1584,1627,1774,1775,1776,1888,1956,2023,2024,2025",
        "WeaponsPlayer": "2051,2052,2053,2054,2055,2057,2058,2059,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2080,2081,2082,2083,2084,";
        "WeaponsHV": "429,669,683,1236,1659,1660,1661,1662,1663,1876",
        "WeaponsSV": "428,429,430,431,432,489",
        "WeaponsCV": "550,551,552,646,647,1582,1637,1638,1639,1640,1641,1673",
        "WeaponsBA": "1648,1649,1650,1651,1673",
        "AmmoPlayer": "2099,2100,2101,2102,2103,2105,2106,2108,2109,2110,2112,2113",
        "AmmoHV": "2104,2200,2208,2211",
        "AmmoSV": "2104,2198,2199,2200,2202,2213",
        "AmmoCV": "2102,2104,2201,2205,2206,2210,2214,2215,2219",
        "AmmoBA": "2102,2104,2201,2204,2209,2216,2217,2218"
      },
    
    The code got addded while the game was not running.
    But everytime I start the game, it removes my code - even before loading the savegame....

    20200710215228_1.jpg 20200710214446_1.jpg
     
    #78
  19. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    @ASTIC

    Bitte hinzufügen ;)
    Code:
      public string DeviceLIds => "259,260,263,278,291,335,336,468,469,498,558,564,653,686,714,717,724,781,960,962,1002,1008,1016,1034,1035,1095,1111,1112,1132,1134,1136,1231,1257,1263,1278,1318,1370,1371,1372,1373,1377,1402,1436,1465,1466,1490,1494,1495,1500,1513,1571,1588,1627,1628,1682,1683,1689,1692,1706,1711,1808,1812,1813,1956,2032,2033,2034,420,457,772,778,835,934,1120,1253,1304,1321,1486,";
     
      public string DeviceSIds => "272,279,418,419,422,423,456,470,471,536,546,547,548,558,653,694,695,696,697,698,1375,1380,1435,1437,1446,1500,1585,1591,1592,603,604,1107,1127,1130,1417,1447,1484,1575,1583,1584,1627,1774,1775,1776,1888,1956,2023,2024,2025, ";
     
      public string WeaponPlayerIds => "2051,2052,2053,2054,2055,2057,2058,2059,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2080,2081,2082,2083,2084,";
     
      public string WeaponHVIds => "429,669,683,1236,1659,1660,1661,1662,1663,1876, ";
     
      public string WeaponSVIds => "428,429,430,431,432,489, ";
     
      public string WeaponCVIds => "550,551,552,646,647,1582,1637,1638,1639,1640,1641,1673, ";
     
      public string WeaponBAIds => "1648,1649,1650,1651,1673, ";
     
      public string AmmoPlayerIds => "2099,2100,2101,2102,2103,2105,2106,2108,2109,2110,2112,2113, ";
     
      public string AmmoHVIds => "2104,2200,2208,2211, ";
     
      public string AmmoSVIds => "2104,2198,2199,2200,2202,2213, ";
     
      public string AmmoCVIds => "2102,2104,2201,2205,2206,2210,2214,2215,2219, ";
     
      public string AmmoBAIds => "2102,2104,2201,2204,2209,2216,2217,2218, ";
     
    #79
  20. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    Version 5.6.2: @Sephrajin The new Ids are included in the list - you have to delete the Ids section in the configuration.json so that the mod enters the (new) default again.
     
    #80
    Kassonnade, Sephrajin and tachyon like this.

Share This Page