[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:
    144
    I've had a look at A12 now and it looks like the background in a projector may be bugged - from what i've tested so far:

    1. Turning off the projector doesn't turn off the background if it's been set. You can do this entirely without scripting just setting up a normal projector with a background then switching it off. The text disappears but the background stays. This might be intended behaviour to stop you having a "wall" that turns on and off or might be a bug that it should be turning off entirely. So any code that turns off the screen would only remove the text as the game itself doesnt remove a background from switching it off

    2. The background can only be set to one of the pre-defined colours, although you can use a hex code it has to match one of the preset colours or it just becomes white - so FF0000 works because red is a predefined colour, but FE0000 doesn't as it doesn't match the shade of red exactly. Somewhat expected as the base game allows setting font colour by tags in the text like <color='FF1111'><color>, but the background can only be chosen from the screens menu. So a script can only set the background to what would normally be allowed by the screen in a normal game

    2b. Also means that transparency/alpha channels dont work for a background as it isn't one of the default colours

    3. When selecting a colour for the background from the menu there IS an option for "no color/transparent", but it doesn't look like this is accessible from a script. I suspect there may be a "name" for this colour in the same way that 'red' is translated to 'FF0000', but I've no idea what it could be. I've tried the obvious ones such as 'clear / hidden / none / null / transparent / invisible' etc and none work, so either the {{bgcolor}} command can't accept something that isnt a name of a colour or hex code (can't see anything in the source code that would indictae this) OR the game itself doesn't have a name for the 'none' colour so it can't be set outside of the menu.


    It looks like so far setting a lcd projector back to transparent isn't possible in a script - it might be worth reporting as a bug that the projector turning off doesn't remove the background as if thats a bug it may get fixed, at which point you can turn off the entire screen and get the desired outcome. or there may be a differet way to do something similar depending on what you're trying to do.

    PS apologies for the lack of German, I'd google translate it but in my experience i'd just be spouting nonsense :)
     
    #41
  2. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    Hi guys I'm just dabbling with scripts and I was wondering with @shadowiviper 's ShipList script is it possible to make it bigger ? I am using lcd projectors for the output screens so ideally I would like it to scale up. Using the ShipStats script works fine with projectors but this doesnt seem to want to size up . I tried removing the fontsize tag but it hasn't done it .
     
    #42
  3. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    Hi @Solutech

    It should be possible to expand it, although with the borders you'd likely need to hardcode it for a specific screen size rather than just having it adapt to any size automatically. It may also end up looking a bit weird as each block would stretch out across the screen but would overall keep the same layout (3 lines in the left column, 3 bars in the right) so may need to change some of the layout around depending on how you want it to look.

    The key bits for changing the size should be:

    Code:
    {{~fontsize 3}}
    {{~set 'E' '<indent=44.5>║</indent>'}}
    
    the general overall font size you already changed, will also affect the borders / bar graphs. Line 2 is how many actual spaces to place the right hand border which is included at the end of every line, so at font size 3 a 0.5x0.5 screen is about 45 characters wide. Best bet is to just keep tweaking that number until the right hand border is in about the right place. Change the 44.5 to a bigger number to move the right border further to the right

    Code:
    <line-height=1>
    {{~#scroll 51 2 4}}{{~#entitiesbyname '*'}}
    
    This may be OK as is, but if the font size is much bigger may need to be increased slightly. A screens normal formatting has a slight gap between each line, so when using the "line" type symbols you can get a solid looking line left-to-right, but always get gaps when going up-down. This decreases the gap between all the lines to give the border a solid appearance, but if the other characters get too much bigger they may start to overlap each other.

    The scroll is for if the number of ships displayed is more than can fit on 1 screen - so is showing "51 lines" and every "2 seconds" scroll down another "4 lines". If your display is a lot taller then increasing the 51 will allow more lines to show at once, and increasing the 4 will make the jump down bigger.

    Code:
    ╔{{~bar 1 0 1  45 '═'}}╗
    
    The top row with the corner pieces at either end - effectively this is creating a "bar graph" of the double line/border 45 characters long (about the width of the 0.5 screen) rather than having "═════" 45 times, to save on the limited number of characters to use per screen. Increase this to about the same as the <indent> from the first block. Increase the 45 so the top line fills out

    Code:
    {{bar 1 0 1  20 '─'}}
    
    Similar to the one above, this is the single width line underneath the ship name, so only goes about halfway across. Change the 20 in line with how much you've increased the other sizes, so if the previous line 45 became 90 start with changing 20 to 40 and adjust as needed

    Code:
    <indent=80%><size=1><b><color=#FFF>{{~math Content '/' Capacity}}{{~format . '{0,8:P2}'}}{{~/math}}</color></b></size>
    
    This is the % number shown overlapping each of the 3 bars , so has a separate <size> a bit smaller than the rest of the screen so the numbers fit "inside" the red/blue/purple bar. If you increase the overall font size then the <size=1> will need to go up a bit as well or the % text will be tiny in a big bar graph


    Code:
    ╚{{bar 1 0 1  45 '═'}}╝
    
    same as the top line, increase the 45 to the number of characters wide the screen is on

    Think that should be everything to just do a direct size increase, but may need to change some of the other <indent=%> values if the layout is a bit wonky. They should mostly be indent=50% to position each of the bars to start halfway across the screen, and then indent=80% to position the percentage value somewhere towards the end of the bar.

    Hope that's of some help :)
     
    #43
    TOFFEL, Phieeel and Sephrajin like this.
  4. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    Fabulous thank you so much I shall have a play :)
     
    #44
  5. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    [​IMG]

    Thats pretty much what I ended up with lol . Much better I can see it now :D

    Code:
    {{~set 'LimitToType' 'SV,HV,CV'}}
    {{~fontsize 7}}
    {{~set 'E' '<indent=275>║</indent>'}}
    {{~set 'L' (concat '║' @root.data.E)}}
    {{~#each E.S.DockedE}}{{~set 'D' (concat @root.Data.D Id ',')}}{{/each}}<line-height=4><color=#FFF>{{~#scroll 51 2 4}}{{~#entitiesbyname '*'}}{{~#sortedeach . 'Distance'}}{{~#test Id neq @root.E.Id}}{{~#test EntityType in @root.Data.LimitToType}}
    ╔{{~bar 1 0 1  60 '═'}}╗
    {{@root.data.L}}
    ║ {{Name}} <indent=85%>[<color=#{{~#test EntityType eq 'BA'}}F00{{/test}}{{~#test EntityType eq 'CV'}}F0F{{/test}}{{~#test EntityType eq 'SV'}}FA0{{/test}}{{~#test EntityType eq 'HV'}}00F{{/test}}>{{EntityType}}</color>]</indent>{{@root.data.E}}
    ╟{{bar 1 0 1  60 '─'}}{{@root.data.E}}
    {{@root.data.L}}{{@root.data.L}}
    ║ <color=#{{#if S.IsPowerd}}1F1{{else}}00220060{{/if}}>Powered</color> {{@root.data.E}}
    {{~use S.FuelTank}}
    <indent=50%><color=#F11>☢ {{bar Content 0 Capacity 10 '▒' '<color=#300>░</color>'}}<indent=80%><size=5><b><color=#FFF>{{~math Content '/' Capacity}}{{~format . '{0,8:P2}'}}{{~/math}}</color></b></size></indent></color></indent>
    {{/use}}{{@root.data.L}}
    ║ <color=#{{#test Id in @root.data.D}}1F1{{else}}00220060{{/test}}>Docked</color> {{@root.data.E}}
    {{~use S.OxygenTank}}
    <indent=50%><color=#11F>✇ {{bar  Content 0 Capacity 10 '▒' '<color=#003>░</color>'}}<indent=80%><size=5><b><color=#FFF>{{~math Content '/' Capacity}}{{~format . '{0,8:P2}'}}{{~/math}}</color></b></size></indent></color></indent>
    {{/use}}{{@root.data.L}}
    ║ {{format (distance Pos @root.E.Pos) '{0,0:N0}m'}} {{@root.data.E}}
    {{~use S.PentaxidTank}}
    <indent=50%><color=#F1F>⚛ {{bar  Content 0 Capacity 10 '▒' '<color=#303>░</color>'}}<indent=80%><size=5><b><color=#FFF>{{~math Content '/' Capacity}}{{~format . '{0,8:P2}'}}{{~/math}}</color></b></size></indent></color></indent>
    {{/use}}{{@root.data.L}}
    ╚{{bar 1 0 1  60 '═'}}╝
    {{/test}}{{/test}}{{~/sortedeach}}{{~/entitiesbyname}}{{/scroll}}
    </color></line-height>
    @shadowiviper Thank you buddy muchly appreciated !
     
    #45
  6. Myrmidon

    Myrmidon Rear Admiral

    Joined:
    Mar 26, 2016
    Messages:
    1,725
    Likes Received:
    2,056


    It does not work for me...

    -A12ExpCreative-_2020-06-09_12-55-59.png
     
    #46
  7. Solutech

    Solutech Ensign

    Joined:
    Jun 7, 2020
    Messages:
    6
    Likes Received:
    4
    Did you make an input screen called Script:ShipList* and an output screen called ShipList?
     
    #47
  8. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    @Solutech awesome that's looking good. Glad you got it working :)

    @Myrmidon As Solutech said, is the screenshot of your 'code' screen like Script:ShipList or is it the intended output 'ShipList'? The actual code can end up looking quite weird as some of the formatting codes (<indent>, <size>, <color>) are part of Empyrion itself so are applied to every screen, even if its just your code to be output elsewhere and can make viewing the code difficult, but should all show normally when you go into the editor by opening the screen
     
    #48
  9. Myrmidon

    Myrmidon Rear Admiral

    Joined:
    Mar 26, 2016
    Messages:
    1,725
    Likes Received:
    2,056
    Now I did.....I forgot that tiny detail :p

    Thank you...It works perfectly now.

    -A12ExpCreative-_2020-06-09_15-19-44.png
     
    #49
  10. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    @Solutech
    One could replace "Capacity 10" with "Capacity 13" to enlarge the progress bars or with "Capacity 9" to reduce it - but so so the numbers have a coherent background either way.

    Thank you (and @shadowiviper ) very much!

    20200628230742_1.jpg 20200629094522_1.jpg

    EDIT:
    And just asking, did anyone figure how to round (cut of) the distance after the dot?
    Eg: Instead of "Distance 23.123456m" to have only "Distance 23m" displayed?
     
    #50
    Last edited: Jun 29, 2020
  11. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    @Sephrajin

    Glad you're having fun with it :) Oddly that list of ships script was probably the one I was least happy with and nearly didn't bother posting as I so rarely looked at it in my own games, knowing that all my ships were in the hangar and I'd given up on a version 2 before I managed to finish it - might be something I can pick back up if/when I start playing again.

    For the distance - as far as I'm aware it should already be rounding to 0 decimal places on this line:

    ║ {{format (distance Pos @root.E.Pos) '{0,0:N0}m'}} {{@root.data.E}}

    The highlighted section is the format used to display the distance to that ship, the codes used for the formatting I still find confusing but "N0" should basically be to display the number to the nearest whole number, and including thousand separators (the full documenation is here if its any help https://docs.microsoft.com/de-de/dotnet/api/system.string.format?view=netframework-4.8#remarks-top)

    I'd initially thought it may have been including thousand-separators, so you had a ship 88 thousand meters away which was displayed as "88,15863m" but that doesn't make sense with there being 5 numbers after the comma so I'm guessing that is just what it's used as it's decimal point (language differences maybe?) - without having a proper look in game the only thing I can suggest would be to remove the "N" from the highlighted section so it reads {0,0:0}m which should take it back to an unformatted number with 0 decimal places, but if that doesn't work I may have a bug somewhere that needs more investigating :)
     
    #51
    Sephrajin likes this.
  12. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Sadly it does not.
    Because you both have it in your code, yet your screenshots show the 'long' values.
    Removing that N does not change the output (not on my end at least), and the only success with rounding numbers using format I had was with ":p2" but that was a percentage value, where the % was automaticly added, so this is not usable in this situation.
    I had spent quit some time yesterday to fix that.. well.. tried to... with no success obviously.
    The only thing I did NOT try - due to lack of understanding - is spliting the value at "," and then use the integer number only.
    I fully support your Math.Round request to Astic though, would ease up such tasks alot :p

    EDIT:
    I started a 'Script - Discussions' thread (because I have a non-working script I need help with), so we can 'keep' this thread for working solutions for everyone.
    https://empyriononline.com/threads/scripting-mod-discussions.94367/
     
    #52
    Last edited: Jun 29, 2020
  13. Jenago

    Jenago Ensign

    Joined:
    Apr 29, 2018
    Messages:
    8
    Likes Received:
    5
    i get this error at the dynamic Transfer script but dont know why
    {{devicesoftype}} error Object reference not set to an instance of an object

    I test it with original box names same error
     
    #53
  14. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    I hadn't yet checked that script in A12 but having had a look I think that error is caused by having a cargo box in the base that hasn't been renamed - so still has for example the default name "Cargo Box".

    When a devie hasn't been renamed it seems any calls to use "CustomName" fail to return a value, rather than using the default name of the device, so where the script finds that box and tries to put its name in the "database", it's trying to use an empty value and throws an error

    The quickest fix would be to make sure every container has a custom name, so renamed something other than the default 'Cargo Box'. It may also be possible to rewrite the script so it uses the device ID instead of name which should always exists - something I'll try to remember if I do a v2.0 sometime
     
    #54
    Sephrajin likes this.
  15. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Name: Autofill
    Description: Toggle wyour docked AND powered off vessesls (HV + SV only) shall be fuelled up (O2, Fuel, Warp), but only if you have more than 1000 of it. (read: it might fuel up o2, but neither pentaxid nor fuel)

    20200630133634_1.jpg 20200630133709_1.jpg

    Switch-txSignal: sw-autofill
    LCDScript: Script:Autofill
    LCDProjectorOutput: Autofill
    CargoBox: Output Power

    Code:
    {{~set 'LimitToType' 'SV,HV'}}
    <pos=0>◜</pos><pos=188>◝</pos>
    <align=center><i><size=150%>Autofill docked vessels</size></i>
    </align><pos=0>◟</pos><pos=188>◞</pos>
    {{#getswitch @root.E.S 'sw_autofill'}}{{#if SwitchState}}
    {{~#each @root.E.S.DockedE}}
    {{#test EntityType in @root.Data.LimitToType}}
    {{#items @root.E.S 'Output Power'}}
    {{#test Count ge 1000}}
    {{#test id eq 2128}}
    {{#fill ../this ../../../S 'Oxygen' 100}}{{/fill}}
    {{/test}}
    {{#test id eq 2373}}
    {{#fill ../this ../../../S 'Fuel' 100}}{{/fill}}
    {{/test}}
    {{#test id eq 2294}}
    {{#fill ../this ../../../S 'Pentaxid' 100}}{{/fill}}
    {{/test}}
    {{/test}}
    {{/items}}
    {{/test}}
    {{/each}}
     
     
    {{else}}
    <color=red>Switch this lever to automaticly fuel up your docked vessels.</color>
    
    
    {{/if}}{{/getswitch}}
    <size=90%>
    {{~set 'IDs' '2373,2294,2128'}}
    {{~#itemlist @root.E.S.items @root.Data.IDs}}
    {{#test count le 1000 }}
    <indent=6>◉ <color=red>Not Enough: <color=#00cccc>{{Name}}</color> (<color=orange>{{Count}}</color>)</color></indent>
    {{else}}
    <indent=6>◉ <color=green>Plenty:</color> <color=#00cccc>{{Name}}</color></indent>
    {{/test}}
    {{/itemlist}}
    </size>
    
    Updated the script as follows:
    * It now lists if you have 0 of a required item, however that is for the base, of the relevant box.
    * It will not fill a specific resource if you have less than 1000 of that stored on the CV/BA (where the script is placed)
    * It looks nicer ;)
     
    #55
    Last edited: Jul 19, 2020
    bbk.3164, tachyon, Phieeel and 2 others like this.
  16. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Name: AutoMove
    Description: Toggle wether it shall move items from your docked vessels to your BA or CV (where the script is running).
    It will search for boxes starting with "Loot" -> so, Loot1, Loot2, .... Loot 99... and move them to your container "Drop Box" of the BA/CV.
    20200701141900_1.jpg
    20200701141911_1.jpg

    Switch-txSignal: sw-automove
    LCDScript: Script:AutoMove
    LCDProjectorOutput: AutoMove
    Code:
     
    <pos=0>◜</pos><pos=188>◝</pos>
    <align=center><i><size=150%>Automove cargo</size></i>
    </align><pos=0>◟</pos><pos=188>◞</pos>
    {{#getswitch @root.E.S 'sw_automove'}}
    {{#if SwitchState}}
    <color=green>Scanning for boxes starting with 'Loot' in docked vessels.</color>
     
     
     
     
    Scanning:
    {{scroll 5 1}}
    {{~#each @root.E.S.DockedE}}
    <indent=6>◉ <color=grey>{{Name}}</color></indent>
    {{#items S 'Loot*'}}
    {{move this @root.E.S 'Drop Box'}}
    {{/move}}
    {{/items}}
    {{/each}}
    {{/scroll}}
    {{else}}
    <color=red>Switch this lever to automaticly move loot from your docked vessels to this structure.</color>
    
    {{/if}}{{/getswitch}}
     
    #56
    Last edited: Jul 2, 2020
  17. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    Very nice. 1 thing I'm not sure if you noticed, the item name being moved displays in German while the other text is English, not sure if that's intentional or not as it's difficult to spot with anything nested in move/fill only showing for a fraction of a second (same as your previous script) - though I think I may have a way of making those logs display for a bit longer that I'm going to experiment with tonight
     
    #57
    Sephrajin likes this.
  18. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    Mini Script: Persistent text
    Description: when using commands like {{fill}} or {{move}} that contain text to show when they are activated, the text only shows for a fraction of a second before the script starts over and the text disappears. Using a rolling script (Script:[+30]) keeps the text on screen, but any other text displayed is repeated endlessly so only the action itself can be shown with no title/styling

    This script surrounds another script, locking it to only run once every 10 seconds. The output is logged to a 2nd backup screen, and restored back to the main display at any point the script isn't running - so text inside a {{move}} command will persist on screen for 10 seconds before the script is next allowed to run and the display resets

    Code:
    {{#test (calc @root.CycleCounter '%' 10) eq 0}}
    {{devices @root.E.S 'Stash'}}
    {{settextblock .0~}}
    
    #put script here
    
    
    {{/settextblock}}
    {{gettext .0}}{{~.~}}{{/gettext}}
    {{/devices}}
    {{else}}
    {{devices @root.E.S 'Dump'}}
    {{gettext .0}}{{.}}{{/gettext}}
    {{/devices}}
    {{/test}}
    
    A 2nd screen named 'Stash' is required to keep a backup copy of the display - and will need the name changed on line 2 if using with multiple scripts so each script has its own uniquely named backup
     
    #58
    Sephrajin likes this.
  19. shadowiviper

    shadowiviper Commander

    Joined:
    Apr 13, 2020
    Messages:
    89
    Likes Received:
    144
    Work in progress, just wanted to see if this was possible.

    Gradient red-to-green fuel tank bar. Same as using {{bar}} but calculates a gradient colour for each step. Pretty impractical and uses up a lot of character limit for zero benefit, and very limited in changing size/style but hopefully can find a use for it later

    upload_2020-7-2_0-43-23.png
    upload_2020-7-2_0-44-9.png
    upload_2020-7-2_0-44-54.png

    Code:
    {{fontsize 5}}
    {{set 'R' 15}}
    {{set 'G' 0}}
    {{split "A,B,C,D,E,F" ","}}{{set "Hex" .}}{{/split}}
    {{#use E.S.FuelTank}}
    {{#math 30 '/' Capacity}}{{#math . '*' ../Content}}
    {{split . '.'}}{{set 'V' (calc .0 '+' 1)}}{{/split}}
    {{/math}}{{/math}}
    {{/use}}
    Fuel: <cspace=0.05em>{{#each @root.OreIds~}}
    {{#test @index leq 30}}
    {{#test @root.Data.R geq 10}}
    {{set 'Hr' (lookup @root.Data.Hex (calc @root.Data.R '-' 10))}}
    {{~else}}
    {{set 'Hr' @root.Data.R}}
    {{~/test}}
    {{~#test @root.Data.G geq 10}}
    {{set 'Hg' (lookup @root.Data.Hex (calc @root.Data.G '-' 10))}}
    {{~else}}
    {{set 'Hg' @root.Data.G}}
    {{~/test}}
    {{~#test @root.Data.G le 15}}
    {{#math @root.Data.G '+' 1}}{{set 'G' .}}{{/math}}
    {{~else}}
    {{#math @root.Data.R '-' 1}}{{set 'R' .}}{{/math}}
    {{~/test}}
    {{~set 'H' (concat @root.Data.Hr @root.Data.Hr @root.Data.Hg @root.Data.Hg "00")~}}
    <color=#{{@root.Data.H}}{{~#test @index ge @root.Data.V}}30{{~/test}}>▏▏</color>
    {{~/test}}
    {{/each}}</cspace>
    
     
    #59
    Last edited: Jul 2, 2020
    tachyon and Sephrajin like this.
  20. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    I forgot to remove that text for filling. :rolleyes:
    But yes, that part was german, which was by accident as I copied it from another CV of mine ;)
     
    #60

Share This Page