[MOD EXT] Empyrion Scripting - Scripts

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

  1. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    this question must have been asked over and over but but how do i even start to make this work ? i have read a lot but i still cant manage to do it , thanks for the hard work btw , love how it looks.
     
    #661
  2. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    993
    Likes Received:
    707
    1. Do not download the source code but the compiled version (https://github.com/GitHub-TC/EmpyrionScripting/releases File: EmpyrionScripting.zip !!!) and unpack it in [EGS]\Content\Mods.
    2. EAC must be switched off for local mods, for server installations EAC must be switched on so that possibly installed local mods do not interfere.
    Then it should run without any further adjustments.
     
    #662
    Necroz likes this.
  3. Blood Cloud

    Blood Cloud Ensign

    Joined:
    Sep 7, 2022
    Messages:
    10
    Likes Received:
    0
    HI I got some issues with automatic looting a fresh "salvaged" ship (de-cored and put salvage core on)

    Code:
    {{#items E.S '*'}}
    {{count}}: {{i18 id}}
    {{#move . @root.E.S 'CargoOut@11975791'}}{{/move}}
    {{/items}}
    {{datetime}}
    I expect this to move every item in any container in to the CargoOut@... container and therefore transfer it to my other ship.
    It does work when i put something myself in the container or if i put something myself into another container.

    The containers of a freshly de-cored ship don't seem to carry any items, except if i manually loot them. (also removing the move, should show me the contents of all containers)

    Neither querying from my ship the containers of the de-cored ship seem to be working: (id is of the de-cored ship, and all are set to faction private) [the query works to a ship i spawned in or build myself]

    Code:
    {{#entitybyid '13250184' }}
    {{#items S '*'}}
    [{{Id}}]:{{Count}} {{Name}}
    {{/items}}
    {{/entitybyid}}
    
    please advice.
     
    #663
    Last edited: Mar 11, 2023
  4. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    thanks for the answer , but after that i just have to copy the lsd displays that have been shared here or i have to code something ? those are the parts that i can understand , then again thanks for the help ! love how it looks and i want to make it work
     
    #664
  5. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    I think you might best start by reading this:
    https://github.com/sri-arjuna/Empyr...ras/Tutorial/Tutorial/1. English - Basics.txt

    Then again, the above "text" is just a "backup" for the blueprint, as I understand it, you have installed the Mod for your local game so you might want to try this:
    https://steamcommunity.com/sharedfiles/filedetails/?id=2863240303

    Then again, reading text and getting an idea how everything is functioning, works without the mod as well - just the examples wont "work", obviously, yet still give you a glimpse.
     
    #665
    Necroz likes this.
  6. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    thanks for answering im still trying to understand , i have 0 notion of coding and stuff and im learning from scratch . thanks for all the help ill read the notes and check on the steam workshop item. thanks again
     
    #666
  7. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    43
    Likes Received:
    7
    I've been trying to do the same kinda thing, but I've run into a problem as well. This code uses the cargo transporter system as well.

    Deposit Box = the box the customer deposits the credits into
    StoreBox =The box that keeps all the store's wares (in this case, I'm using the CargoIN as the StoreBox)
    Checkout = the box where the customer picks up their goods
    CashBox =Where the credits are deposited (in this case, it goes into a CargoOut@ container to send the money to HQ)

    I can get the code to check to see the amounts of the sale items and credits. I can also get the code to run continously until it runs out of product or the credits deposited runs out. Only issue is, I can't get the script to run more than once without manually empyting one of the destination boxes. However, if I empty the cashbox, the script will place more credits there without placing additional items in the checkout box. Any ideas?

    Code:
    {{set 'SaleItem' '4341'}}
    {{set 'SaleAmount' '2'}}
    {{set 'Credits' '4344'}}
    {{set 'CreditPrice' '10'}}
    {{set 'Commodity' ''}}
    {{set 'CommodPrice' ''}}
    {{set 'StoreBox' 'CargoIn'}}
    {{set 'Checkout' 'Checkout'}}
    {{set 'Deposit' 'Pentaxid'}}
    {{set 'CashBox' 'CargoOut@'}}
    {{set 'Stocked' ''}}
    {{set 'Paid' ''}}
    
    {{#items E.S. @root.Data.StoreBox}}
      {{#test Id in @root.Data.SaleItem}}
        {{#test Count 'geq' @root.Data.SaleAmount}}
          {{set 'Stocked' 'true'}} 
        {{else}}
          {{set 'Stocked' 'false'}} 
        {{/test}}
      {{else}}
        {{set 'Stocked' 'false'}}
      {{/test}}
    {{else}}
    {{set 'Stocked' 'false'}}
    The store is empty
    {{/items}}
    
    {{#items E.S. @root.Data.Deposit}}
      {{#test Id in @root.Data.Credits}}
        {{#test Count 'geq' @root.Data.CreditPrice}}
          {{set 'Paid' 'true'}} 
        {{else}}
          {{set 'Paid' 'false'}} 
        {{/test}}
      {{else}}
        {{set 'Paid' 'false'}}
      {{/test}}
    {{else}}
    {{set 'Paid' 'false'}}
        Deposit {{@root.Data.CreditPrice}} credits to purchase {{@root.Data.Deposit}}
    {{/items}}
    
    {{#ok @root.Data.Stocked}}
       {{#ok @root.Data.Paid}}
        {{#items E.S. @root.Data.StoreBox}}
          {{#test Id in @root.Data.SaleItem}}
            {{#move this @root.E.S @root.Data.Checkout @root.Data.CreditPrice}}
            {{/move}}
          {{/test}}     
        {{/items}}
        {{#items E.S. @root.Data.Deposit}}
          {{#test Id in @root.Data.Credits}}
            {{#move this @root.E.S @root.Data.CashBox @root.Data.CreditPrice}}
            {{/move}}
            {{set 'Paid' 'false'}}
         {{/test}}     
        {{/items}}
      {{/ok}}
    {{else}}
      This item is out of stock. Please come back later.
    {{/ok}}
     
    #667
  8. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    44
    Likes Received:
    11
    My understanding is that "{{#items S '*'}}" and similar tags only work with custom named containers due to limitations in the API that Eleon makes available to modders. Unfortunately this means that if whoever made the ship you are trying to loot did not rename their containers from the default, then Empyrion Scripting cannot see inside them.

    Someone please correct me if I am wrong. I would LOVE to have an automatic ship/POI looting script myself.
     
    #668
    Blood Cloud likes this.
  9. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    thanks for all the help i was able to make a couple work fine but im trying to use the Floor Plan and dosent work , even following the instructions video , if you can help me i would apreciate it , thanks again for the work its amazing.
     
    #669
  10. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    43
    Likes Received:
    7
    Is there a way to use the {{move}} command to just move a certain amount of an item to a destination container regardless of how much is already in the destination container? Example if I'm moving 2 pentaxid to a container that has 25 pentaxid, I want to add 2 to the pentaxid that's already in the destination container(25).

    And Astic, is there a loop command? goto? anything of that nature?
     
    #670
  11. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    44
    Likes Received:
    11
    As far as I can tell, there is not a direct way to do so. What I am doing in my 2nd attempt at rewriting the Dynamic Sort script is essentially...
    Code:
    {{#getitems @root.E.S 'Target Container Name'}}
    {{#each .}}
    {{test id eq 'Item ID to add'}}
    {{set 'Quantity' (calc count '+' '2')}}
    {{move . @root.E.S 'Target Container Name' @root.Data.Quantity}}
    {{~set 'MoveActivity' (concat @root.Data.MoveActivity (datetime 'd') ' @ ' (datetime 'T') ': Moved ' Count ' extra ' (i18n id) ' from ' Source ' to ' Destination '.
    ')}}
    {{~/move}}
    {{@root.Data.MoveActivity}}
    {{/test}}
    {{/each}}
    {{/getitems}}

    I asked a similar question a while back in the Empyrion Scripting Mod thread here, and got no response. I am taking that to mean the answer is unfortunately no.
     
    #671
  12. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Also @Mycroft_Groks

    Define "Loop".
    Strictly speaking, every script is some sort of a loop, as they are get executed every cycle, which basicly is the definition of a loop.
    But I'm quite sure you have something different in mind.
     
    #672
  13. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    44
    Likes Received:
    11
    For me, "Loop" would be the ability to repeat a specific section of code without repeating the rest of the code - preferably with a way to jump to it, then jump back to where you were. IE: something like either (or both) of the following fake pseudo code snippets...
    Code:
    {{!-- Example 1 --}}
    Long stretch of code here...
    {{While Switch = On}}
    Small stretch of code here...
    {{/While}}
    Another long stretch of code here...
    
    
    {{!-- Example 2 --}}
    Long stretch of code, resulting in selection of an item that needs to be moved...
    {{Gosub 'MoveIt'}}
    {{Goto 'SkipMoveIt'}}
    {{::MoveIt::}}
    Half dozen or so lines of code to move an item and display the results...
    {{Return}}
    {{::SkipMoveIt::}}
    Another long stretch of code, resulting in selection of an item that needs to be moved...
    {{Gosub 'MoveIt'}}
    Another long stretch of code...
    More code...
    Another long stretch of code, resulting in selection of an item that needs to be moved...
    {{Gosub 'MoveIt'}}
    More code...
    
    Both options can semi-sort of be faked by using nested {{If <variable>}} and similar statements, but that can make the logic hard to follow when you have 3 or 4 {{If <variable>}} variants all skipping 95% of your code.
    The Gosub/goto type of syntax would have the (extremely helpful) advantage of reducing the length of scripts, making it easier to fit in the 2000 character limit.
     
    #673
  14. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39

    hello , love the work done here , i try to make it work but the blue bar only blinks instead of showing a bar , despite followin the instructions i cant make it work , if you can help me i would appreciate it , thanks again and amazing work
     
    #674
  15. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Yeah ok, that is hard to achieve.
    There is a(nother) workaround to that, though, of course the following is not always applicable...

    For my HUD, I was reaching the character limit with just 1 cargo display.
    So I've 'extracted' that code (~1k chars) to another LCD, and "included" them in the "HUD Main" code.
    Code:
    {{~devices @root.E.S 'HUD_*'}}{{~#each .}}<line-height=8>
    {{~gettext .}}<size=4>{{.}}
    </size>{{~/gettext}}
    {{/each}}{{~/devices}}
    
    So you could write a handler, that - depending on "results", includes one LCD or another - so to say.
    I think we cannot get actual loops for.... performance reasons... (infinite loops on a server sounds really bad to me).

    Hope this help
     
    #675
  16. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Sounds to me that you forgot to add [+120] in the LCD name of the script.
    Code:
    Script:[+120]FuelLog
    Its the first entry of the LCD Input Name.

    EDIT:
    That said, you only need it on the Script LCD -- NOT for the output.
     
    #676
    Necroz likes this.
  17. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    thanks it worked like a charm , if by any chance do you know how to make autoharvest plants ( the one with the gardener ) and Floorplan ( for the base ) i would appreciate it , even more if you got the right script . thanks again for the help
     
    #677
  18. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    993
    Likes Received:
    707
    Floorplan is a Svagegamescript you can get from https://github.com/GitHub-TC/EmpyrionScripting-Collection
     
    #678
    Necroz likes this.
  19. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    #679
  20. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,917
    Ok, you succeeded (ok, inspired, because the players on our server 'need' a shop now), I'm working on a shop script :D
    At least the dynamic Price retrievel and check for proper payment seems to be working as of now.

    Left has a "non-Platin Card" item as payment, where as the right one contains proper payment.
    [​IMG]
     
    #680

Share This Page