[MOD EXT] Empyrion Scripting - Scripts

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

  1. Verdauga

    Verdauga Ensign

    Joined:
    Nov 18, 2022
    Messages:
    1
    Likes Received:
    0
    Am bashing head against wall. Coming to the experts.

    I have been trying to make a shop front script, without using elevated, as i am not admin.

    Please note that on this server, both Credit and Pentaxid stack to 50k. There are also no weights/volumes.

    The setup: I have 5 boxes, an LCD for the code, and an LCD to give the user an idea of what's going on.

    5 boxes are:
    • RawIngredients (hosting lumps of Pentaxid Crystals to be purchased, and Credits to be spent by the Gardener
    • MoneyIN. This is the unlocked box that the customer has access to. Into this, they are instructed to put 10,000 credits.
    • MoneyOUT. This is the box that money is moved to, after payment, but before being moved into RawIngredients. More on this later.
    • PentaxIN. This is a staging box, hosting 50k Pentaxid, waiting for 15,000 of it, to be brought into the next box...
    • PentaxOUT. This is the box that the customer has access to, to withdraw their goods.
    2 LCDs are:
    • Script:sellstuff
    • sellstuff
    I couldn't find anyone who'd done something similar (although I fully expect it exists, I just couldn't find it), so I cut this code together to do it.

    If you want to test this code on a single LCD, you will need to extact all the ! comments, or it won't fit. I've put them in here, so you can follow.

    <code>
    {{#items E.S 'PentaxIN'}}
    <align=center><size=6>Welcome to the shop.
    ☚Credits IN. Pentax OUT ☛</size></align>
    {{#test Id 'eq' 4341}}
    {{#test Count 'leq' 20000}}
    {{!check the PentaxIN box has 20k Pentax, before starting process. Don't want to process a transaction if there's not enough}}
    {{set 'Payed' true}}
    {{!Payed is a variable i'm using to halt the transaction. True, and the process stops.}}
    <color=red>There is less than 20,000 Pentaxid in the box. Please come back later when there is more in stock.</color>
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyIN'}}
    There is{{format Count '{0,5}'}} {{Name}}
    in the box.
    {{#test Id 'eq' 4344}}
    {{#test Count 'eq' 10000}}
    {{set 'Found' true}}
    {{!Look in the MoneyIN box for credits, and validate there's 10k, and nothing else. Then Found is the variable i'm using to progress the transaction}}
    Thank you for the correct deposit.
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'PentaxOUT'}}
    <color=red>Remove the Pentax from the outbox before another transaction can process.</color>
    {{#test Id 'eq' 4341}}
    {{set 'Payed' true}}
    {{!If there's pentax in the outbox, it'll be because someone's not emptied it. Because the move script only tops the destination up to 15k pentax, I need it to have none in there, or they'd get short-changed}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyOUT'}}
    <color=red>Money is still being processed internally. Please wait.</color>
    {{#test Id 'eq' 4344}}
    {{set 'Payed' true}}
    {{!Much like moving the Pentax into the outbox would not complete it, i'm checking the target box contains no money, before letting them proceed}}
    {{/test}}
    {{/items}}
    {{#if @root.Data.Found}}
    Money Detected. Thank you for your payment.
    {{!Money is in the box, no failure conditions have been detected at this stage}}
    {{#if @root.Data.Payed}}
    Payment transactions have stopped. The reason is highlighted in <color=red>RED</color>.
    {{else}}
    <color=green>Transaction in progress. Please wait...</color>
    {{#items E.S 'MoneyIN'}}
    {{~set 'sellstuff' ''}}
    {{~set 'Amount' '10000'}}
    {{!Move 10k from inbox to outbox}}
    {{#test Id in '4344'}}
    {{~set 'sellstuff' 'MoneyOUT*'}}
    {{/test}}
    {{#ok @root.Data.sellstuff}}
    {{#move ../. @root.E.S @root.Data.sellstuff @root.Data.Amount}}
    Credits Moved.
    {{Source}} -> {{Destination}}
    {{!Writing something on the screen helps me track progress through the script}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{#items E.S 'PentaxIN'}}
    {{~set 'sellstuff' ''}}
    {{~set 'Amount' '15000'}}
    {{!movethepentax}}
    {{#test Id in '4341'}}
    {{~set 'sellstuff' 'PentaxOUT*'}}
    {{/test}}
    {{#ok @root.Data.sellstuff}}
    {{#move ../. @root.E.S @root.Data.sellstuff @root.Data.Amount}}
    {{datetime}}
    {{Source}} -> {{Destination}}
    {{format Count '{0,5}'}}:
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/if}}
    {{/if}}
    </code>

    This works perfectly. Money in, pentaxid out.

    However, there's a bug. If the user deposits the 10,000 credits, and doesn't exit the trade window, the script can't pull the cash, skips that section, and moves to deposit the pentax into PentaxOUT.

    So, I have decided to try and validate that the money has been transferred into the MoneyOUT box, before moving the Pentax. I have written the code, but for some reason, while the money transacts, it won't serve up the pentax. I cannot figure it out.

    The digits 1 and 2 here, show where the failure is. 1 is written to the screen, and 2 isn't. It won't drop into the next #items clause. WHY?! Brainpower exhausted. Can't figure out how the final aspect of the script should work. I'm thinking that the final aspects should be nested...

    <code>
    {{#items E.S 'PentaxIN'}}
    {{#test Id 'eq' 4341}}
    {{#test Count 'leq' 20000}}
    {{set 'Payed' true}}
    <color=red>There is not enough Pentaxid to transact. Please come back later</color>
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyIN'}}
    There is {{format Count '{0,5}'}} {{Name}} in the box.
    {{#test Id 'eq' 4344}}
    {{#test Count 'eq' 10000}}
    {{set 'Found' true}}
    Thank you for the correct deposit.
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'PentaxOUT'}}
    <color=red>Remove the Pentax before another transaction can process.</color>
    {{#test Id 'eq' 4341}}
    {{set 'Payed' true}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyOUT'}}
    <color=red>Money being processed. Please wait.</color>
    {{#test Id 'eq' 4344}}
    {{set 'Payed' true}}
    {{/test}}
    {{/items}}
    {{#if @root.Data.Found}}
    Money Detected. Thank you for your payment.
    {{#if @root.Data.Payed}}
    Payment transactions have stopped. The reason is highlighted in <color=red>RED</color>.
    {{else}}
    <color=green>Transaction in progress. Please wait...</color>
    {{#items E.S 'MoneyIN'}}
    {{~set 'CashIN' '10000'}}
    {{#test Id in '4344'}}
    {{~set 'CashTarget' 'MoneyOUT'}}
    {{/test}}
    {{#ok @root.Data.CashTarget}}
    {{#move ../. @root.E.S @root.Data.CashTarget @root.Data.CashIN}}
    Credits to OUT.
    {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}
    1
    {{#items E.S 'MoneyOUT'}}
    2
    {{#test Id 'eq' 4344}}
    {{#test Count 'eq' 10000}}
    {{#items E.S 'PentaxIN'}}
    {{~set 'PentaxOUT' '15000'}}
    {{#test Id in '4341'}}
    {{~set 'PentaxTarget' 'PentaxOUT'}}
    {{/test}}
    {{#ok @root.Data.PentaxTarget}}
    {{#move ../. @root.E.S @root.Data.PentaxTarget @root.Data.PentaxOUT}}
    Pentax Moved
    {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{#items E.S 'MoneyOUT'}}
    {{~set 'EmptyMoney' 'RawIngredients'}}
    {{#ok @root.Data.EmptyMoney}}
    {{#move ../. @root.E.S @root.Data.EmptyMoney ''}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/test}}
    {{/test}}
    {{/items}}
    {{/if}}
    {{/if}}
    </code>

    -EDIT-

    So, i have solved one problem. If the MoneyIN box is held open, the following script will validate that the money has been transferred before transferring in, the pentax.

    However, the script now takes a good deal longer to execute, because it has to run the validation.

    Also, if the buyer opens (and holds open) the PentaxOUT box, i'm not yet validating that the item was delivered.

    {{#items E.S 'PentaxIN'}}
    {{#test Id 'eq' 4341}}
    {{#test Count 'leq' 20000}}
    {{set 'Payed' true}}
    {{set 'MoneyMoved' false}}
    <color=red>There is not enough Pentaxid</color>
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyIN'}}
    You have deposited {{format Count '{0,5}'}} {{Name}}
    {{#test Id 'eq' 4344}}
    {{#test Count 'eq' 10000}}
    {{set 'Found' true}}
    Thank you for the correct deposit.
    {{/test}}
    {{/test}}
    {{/items}}
    {{#items E.S 'PentaxOUT'}}
    <color=green>Remove your Pentaxid ☛</color>
    {{#test Id 'eq' 4341}}
    {{set 'Payed' true}}
    {{/test}}
    {{/items}}
    {{#items E.S 'MoneyOUT'}}
    <color=red><size=10>The transaction is validating. Please wait. Do not open the Pentax box ☛✖</color>
    {{#test Id 'eq' 4344}}
    {{set 'Payed' true}}
    {{/test}}
    {{/items}}
    {{#if @root.Data.Found}}
    Money Detected.
    {{#if @root.Data.Payed}}
    Payment transactions have stopped.
    {{else}}
    <color=green>Transaction in progress...</color>
    {{#items E.S 'MoneyIN'}}
    {{~set 'CashIN' '10000'}}
    {{#test Id in '4344'}}
    {{~set 'CashTarget' 'MoneyOUT'}}
    {{/test}}
    {{#ok @root.Data.CashTarget}}
    {{#move ../. @root.E.S @root.Data.CashTarget @root.Data.CashIN}}
    Credits: {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/if}}
    {{/if}}


    {{#items E.S 'MoneyOUT'}}
    {{#test Id 'eq' 4344}}
    {{#test Count 'eq' 10000}}
    {{~set 'MoneyMoved' true}}
    {{/test}}
    {{/test}}
    {{/items}}

    {{#if @root.Data.MoneyMoved}}
    {{#items E.S 'PentaxIN'}}
    {{~set 'PentaxOUT' '15000'}}
    {{#test Id in '4341'}}
    {{~set 'PentaxTarget' 'PentaxOUT'}}
    {{/test}}
    {{#ok @root.Data.PentaxTarget}}
    {{#move ../. @root.E.S @root.Data.PentaxTarget @root.Data.PentaxOUT}}
    Pentax {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}

    {{#items E.S 'MoneyOUT'}}
    {{~set 'EmptyMoney' 'RawIngredients'}}
    {{#ok @root.Data.EmptyMoney}}
    {{#move ../. @root.E.S @root.Data.EmptyMoney ''}}
    Credits {{Source}} -> {{Destination}}
    {{/move}}
    {{/ok}}
    {{/items}}
    {{else}}

    {{/if}}
     
    #621
    Last edited: Feb 9, 2023
  2. tactician2

    tactician2 Ensign

    Joined:
    Feb 7, 2023
    Messages:
    1
    Likes Received:
    0
    any update to this the move 50 to constuctor input doesnt seem to function properly anymore
     
    #622
  3. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Was ist eigentlich aus dem Projekt von Astic mit dem Autominer geworden ?
     
    #623
  4. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    Was meinst du mit Autominer?
    Ich habe per Scripting die Möglichkeiten die “TerrainPlaceables“ zu ermittelten, mehr lässt die API leider nicht zu.

    Spoiler: Bisher stehen die Chancen gut das wir in der 1.10.x auch die Konstruktoren per Script steuern können.
     
    #624
  5. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    [​IMG]
    Ich nahm an, das ähnlich wie bei Gärtner die Miner abgefragt, das Erz entnommen wird und die wieder aufgetankt werden.
     
    #625
    Last edited: Feb 11, 2023
  6. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    Das, währe schön und würde ich sofort machen, nur komme ich leider an die Daten des Autominers nicht dran - in der Datenbank steht nur der Typ, seine Position und ob er für die Fraktion freigegeben ist. Alles weitere verbirgt sich in den Dateninternas von Empyrion auf die ich keinen Zugriff habe.

    So bleibt nur die z.B. Position der Autominer auszulesen bzw. alle Autominer einer Fraktion mit ihren Positionen/Playfields aufzulisten
     
    #626
  7. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Gut und vielen Dank für die Antwort. :)
     
    #627
  8. Lucifercalls

    Lucifercalls Ensign

    Joined:
    Feb 12, 2023
    Messages:
    2
    Likes Received:
    0
    Guten Tag
    euer Script is wirklich super.
    leider habe ich dazu 2 fragen wo wir Hilfe benötigen.
    1 kann man bestimmte Scripts verbietet so nur der Deconstruct geht rest nicht.

    2 wir suchen ganze zeit die Einstellung das der Deconstruct Blöcke abbaut wie Stahlblock als Würfel nicht so wie das schiff gebaut ist oder alien Blöcke bekommen nicht Spawner oder die Waffen Weiss das geht irgendwie.

    leider sind wir nicht ganz der Englischen Sprache mächtig.

    Mit freundlichen grüßen
     
    #628
  9. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    1. Nein
    2. Die aktuelle Version reduziert den abgebauten Block immer auf seinen Ursprungszustand. Die zu ignorierenden Blöcke kann man in der Konfiguration anpassen ändern

    EGS\Saves\Games\SAVEGAMENAME\Mods\EmpyrionScripting\Configuration.json
    Code:
      "DeconstructBlockSubstitution": {
        "331": 0,
        "541": 0,
        "542": 0,
        "543": 0,
        "544": 0
      },
     
    #629
  10. Lucifercalls

    Lucifercalls Ensign

    Joined:
    Feb 12, 2023
    Messages:
    2
    Likes Received:
    0
    Vielen dank für die Hilfe =)
     
    #630
  11. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    I am still looking for an answer to this one. Any assistance would be greatly appreciated. :)
     
    #631
  12. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    #632
  13. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    I'm not sure where to even begin trying to set that up (looks like it needs to be spread across 17 different LCDs?), and looks like it would need to be modified for each individual ship/base (I could be wrong on that - I didn't really understand the script flow when I read through everything).
     
    #633
  14. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    Well, kind of yes.
    It requires multiple 'stage' cargo boxes.
    All boxes (but stage ones) need to be following this syntax: prefx-description-id
    Same for the LCD, thus you only need 1 script to label all the boxes with their content (unless box/lcd bug).
    If you name the boxes as the script suggest, you wont need to adjust the scripts - but yes you'll need a specific setup.

    Just seen, ignore "autosort-io" thats an old - leftover - script.

    You do need StageSort1-13 and you will want the AlarmMaualSort, so 14 scripts.
    StageSort 1 takes its stuff from a *Box Drop*, and then start moving items through all the stage where each script sort different things.
    It is set up that way, because if you parse more than like 60-80 boxes at once, the playfield starts to become laggy.
     
    #634
  15. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    That's major overkill for my needs, as I generally only have about a half dozen containers per ship/base. I just want something that will automatically move perishables to the fridge, ammo & weapons to the ammo controller, ores & components to the harvest controller, and everything else to the cargo controller.
     
    #635
  16. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Bei dem "Unversal Container" von Shadowiviper erfolgt die Ausgabe, trotz CultureInfo, nur in Englisch.
    Habe noch keinen Weg gefunden das umzuändern.
    Zu CulturInfo: muß das nur einmal auf einem Playfield angegeben werden oder in jedem "Objekt" darauf.
    MfG
    BugiTree
     
    #636
  17. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    Pro
    Pro Objekt, da die Sprache ja immer anders sein kann.
     
    #637
  18. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    Is there a way to sort a list of data? IE: Something like the following (which definitely does not work)...
    Code:
    {{set 'List' '1,3,9,6,7,2,5,4,8'}}
    {{sort @root.Data.List}}
    Sorted list is...
    {{@root.Data.ListArray}}
    
    The 'sort', 'orderedeach', 'order', etcetera commands all seem to require actual arrays with key:data pairs and therefore will not work on simple lists.

    While not preferred, converting the list to an array with an added key (IE: [ 'MyKey':'1','MyKey':'3','MyKey':'9' ] or similar) would be an acceptable workaround for me, but I cannot figure out how to use 'set' (or any other commands I could find) to add the key.
     
    #638
  19. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
  20. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,085
    Likes Received:
    731
    I will implement this but your example is wrong because '1,2,3,4,5,6' is a text, only with a {{split ... }}} it becomes an array ;-)
    PS: I'll get back to you when the sorting can also handle simple lists.
     
    #640
    Shadowpheonix likes this.

Share This Page