[MOD EXT] Empyrion Scripting - Scripts

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

  1. Sephrajin

    Sephrajin Rear Admiral

    Joined:
    Dec 22, 2017
    Messages:
    916
    Likes Received:
    2,918
    The "issue" is, the CreditPrice in your move command.
    Its not precicly "move that many", but "up to that point".

    Say, it'll move items only until said amount in the destination is reached - since we buy "1", it'll wont move any more as long that "1" is in the destination.



    This is precicly the point where i'm stuck now...
    I 've tried to set up a store with an array.. so multiple boxes, works via "index-naming"...

    Basicly, Its stuck when I try to move the money from "Cash_In" (where customer money is placed - as payment) to "Cash_deposit" (where the store money is 'safe'), meainwhile, I try to move the item from a temporary storage to an outbox, each with another move command that does not rely on the amount passed - but would move 'everything' of given item.
    Code:
    {{~set 'ItemKey' 'AsgardArmorDonat,WaterJug'}}
    {{~set 'Amount' '1,10'}}
    {{~set 'Price' '1000,1'}}
    {{~#split @root.data.ItemKey ','}}{{set 'aKey' .}}{{/split}}
    {{~#split @root.data.Amount ','}}{{set 'aAmount' .}}{{/split}}
    {{~#split @root.data.Price ','}}{{set 'aPrice' .}}{{/split}}
    {{~#split @root.data.ItemKey ','}}
    {{#each .}}
        {{~set 'CleanUp' '0'}}
        {{~set 'tAmount' (lookup @root.data.aAmount @index)}}
        {{~set 'tPrice' (lookup @root.data.aPrice @index)}}
        {{~set 'Stock' (concat 'Stock-Item-' @index)}}
        {{~set 'Buy' (concat 'Buy-Item-' @index)}}
        {{~set 'N' (i18n .)}}
        {{~#devices @root.E.S (concat "Price-" @index )}}{{~#each .}}{{settext . @root.data.tPrice }}{{/each}}{{/devices}}
        {{~#devices @root.E.S (concat "item-" @index )}}{{~#each .}}{{settext . @root.data.N }}{{/each}}{{/devices}}
        {{#items @root.E.S @root.data.Stock}}
            {{#test key eq (lookup @root.data.aKey @index)}}
                {{~#test Count geq @root.data.tAmount}}
                    {{~#items @root.E.S @root.data.Buy}}
                        {{~#test Key eq 'PlatinumCard'}}
                            {{~#test Count geq @root.data.tPrice}}
                                {{~#move this @root.E.S 'Cash_In' @root.data.tPrice}}
                                    {{~#move ../../../../this @root.E.S @root.data.Buy @root.data.tAmount}}
                                        {{~set 'CleanUp' '1'}}
                                    {{/move}}
                                {{/move}}
                            {{/test}}
                        {{/test}}
                    {{/items}}
                {{/test}}
            {{/test}}
        {{/items}}
        {{~#test @root.data.CleanUp geq '1'}}
    {{datetime}} Bug starts here
            {{~#items @root.E.S 'Cash_In'}}
    Debug:    k{{key}} c{{count}}
                {{~#move this @root.E.S 'Cash_Depot'}}
    Debug:    Deposit
                    {{~set 'CleanUp' '0'}}
                {{/move}}
            {{/items}}
          
            {{~#items @root.E.S @root.data.Buy}}
                {{~#test key eq (lookup @root.data.aKey @index)}}
    Debug:    k{{key}} c{{count}}
                    {{~#move this @root.E.S (concat 'Out-' @index)}}
    Debug:    Item to box out
                        {{~set 'CleanUp' '0'}}
                    {{/move}}
                {{/test}}
            {{/items}}
        {{/test}}
    {{/each}}
    {{/split}}
     
    #681
  2. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    hello again , thanks for all the help and i have learned a lot but i still dont manage to make Floorplan and autoharvest (the one with the gardener ) functionals , if anyone can help me or have the right script i would appreciate it . ps: is there a script that shows your on/off devices/weapons/etc on BA/SV/CV/HV . once again thanks for the help !

    safe travels , like always love the game so far , now with the scripts even more
     
    #682
  3. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    1. For Harvest, look closely at how it is done on the DemoCV and how it works there.
    2. For the floorplan, post the path to the floorplan.cs where it is located and the content of the configuration.json from EmpyrionScripting in your savegame. Also post the name of the LCD on which the floor plan is to be displayed.
     
    #683
  4. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    I'm going to try what Shadowphoenix suggested in the previous page
    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}}
    Unfortunately, I think this will cause the script to go over the 2000 character limit, BUT in doing so, I can combine all the scripts for the various boxes and get them to work in one script.

    I'm going to try the above.
     
    #684
  5. lolodu099

    lolodu099 Ensign

    Joined:
    Dec 12, 2016
    Messages:
    9
    Likes Received:
    1
    so you can"t empty out default storage buut can you do it if you tag them with a script or maybe rename the entire ship compound to XXX(1-2-...) ? or is it impossible
     
    #685
  6. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    If you go through and manually assign a name to every container, then you can empty it via script. Unfortunately, manually assigning the names takes just as long and is just as annoying as manually emptying the containers so it is not really a better option.
     
    #686
  7. Necroz

    Necroz Lieutenant

    Joined:
    May 21, 2020
    Messages:
    49
    Likes Received:
    39
    hello , i been having a problem with some LCDs that display the ships docked and other ones , the thing is they work fine until i leave the planet and comeback , then all those lcd instead of showin information , show this message : Exception has been thrown by the target of an invocation. 15:24:39" , if anyone can help , i would apreciate it .
     
    #687
  8. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    OK... I am EXTREMELY confused right now...

    [​IMG]

    Here's the relevant code snippet...
    Code:
    Current Count = {{@root.Data.CurrentCount}}
    Desired Quantity = {{@root.Data.Quantity}}
    {{~test @root.Data.CurrentCount ge @root.Data.Quantity}}
    <b> </b>
    Count is greater than quantity.
    <b> </b>
    {{~set 'Excess' (trim (calc @root.Data.CurrentCount '-' @root.Data.Quantity))}}
    {{~#getitems @root.E.S @root.Data.Container-Deposits}}
    {{~#each .}}
    {{~set 'TempCount' (trim Count)}}
    {{~set 'TempID' (trim ID)}}
    {{~test @root.Data.TempID eq @root.Data.CurrentID}}
    {{~set 'Excess' (trim (calc @root.Data.TempCount '+' @root.Data.Excess))}}
    {{~/test}}
    {{~/each}}
    {{~/getitems}}
    {{~set 'NewText' ''}}
    {{~move . @root.E.S @root.Data.Container-Deposits @root.Data.Excess}}
    {{~set 'NewText' (trim (concat @root.Data.NewText '
    '(datetime 'd') ' @ ' (datetime 'T') ':
        Moved ' Count ' excess ' (i18n ID) '
        from ' Source ' to ' Destination '.'))}}
    {{~/move}}
    {{~OK @root.Data.NewText}}
    {{@root.Data.NewText}}
    {{~/OK}}
    {{~else}}
    <b> </b>
    Count is less than quantity.
    <b> </b>
    {{~/test}}

    Screenshot & code don't show it, but I tried using "{{~test (trim @root.Data.CurrentCount) ge (trim @root.Data.Quantity)}}" in case there were spaces or something I wasn't seeing, and it made no difference.
     
    #688
  9. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    With an operation like "trim" you turn numbers into text and as text 1xxx is smaller than 2xx
    So you should remove all "trim" operations or convert the text to a number with a (calc 0 '+' textvalue).
     
    #689
  10. Shadowpheonix

    Shadowpheonix Lieutenant

    Joined:
    May 19, 2022
    Messages:
    46
    Likes Received:
    12
    That would explain it. I was using "trim" because I was randomly getting ID values like " 1098" which was causing things to fail in other parts of my script (likely a variant of this same issue, as they were parsed out of a string containing a mix of text & numbers). Adding the "trim" commands to the number specific pieces seemed to fix that issue for those other parts of my code, but not this particular section. I will try switching to the (calc 0 '+' textvalue) method instead for everything that actually uses the numbers.

    Thank you again for the continued prompt & helpful responses. It is very much appreciated.
    (If Eleon hasn't already made you a job offer, they absolutely should. :D)
     
    #690
  11. Blood Cloud

    Blood Cloud Ensign

    Joined:
    Sep 7, 2022
    Messages:
    10
    Likes Received:
    0
    is there a way of setting the CustomName on a Container that does not have it?

    Code:
    {{#devicesoftype @root.E.S 'Container'}}
      {{#each . }}
        {{#if CustomName}}
          GET:{{CustomName}}
        {{else}}
          SET:{{CustomName}}
        {{/if}}
      {{/each}}
    {{/devicesoftype}}
    the SET: something like {{set this.CustomName 'blabla'}}
     
    #691
  12. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Eleon has not provided API calls for this.
     
    #692
  13. Blood Cloud

    Blood Cloud Ensign

    Joined:
    Sep 7, 2022
    Messages:
    10
    Likes Received:
    0
    Something like this ?
    Code:
    {{#test (calc @root.CycleCounter '%' 10) eq 0}}
    {{~set 'SourceB' '.Salvage:*'}}
    {{~set 'OreL' Ids.Ore}}
    {{~set 'OreB' 'Loot: Ore'}}
    {{~set 'MedsB' 'Loot: Meds'}}
    {{~set 'MedsL' Ids.Medic }}
    {{~set 'IngotL' Ids.Ingot}}
    {{~set 'IngotB' 'Loot: Ingot'}}
    {{~set 'HandL' (concat Ids.AmmoPlayer Ids.WeaponPlayer Ids.Tools)}}
    {{~set 'HandB' 'Loot: Handheld'}}
    {{~set 'AmmoL' (concat Ids.AmmoHV Ids.AmmoSV Ids.AmmoCV Ids.AmmoBA)}}
    {{~set 'AmmoB' 'Loot: Ammo'}}
    {{~set 'WeaponL' (concat Ids.WeaponHV Ids.WeaponSV Ids.WeaponCV Ids.WeaponBA)}}
    {{~set 'WeaponB' 'Loot: ShipWeapons'}}
    {{~set 'DeviceL'(concat Ids.DeviceL Ids.DeviceS)}}
    {{~set 'DeviceB' 'Loot: Devices'}}
    {{~set 'BlockL'(concat Ids.BlockL Ids.BlockS)}}
    {{~set 'BlockB' 'Loot: Blocks'}}
    {{~set 'PerishL'(concat Ids.Food Ids.Ingredient Ids.Sprout ',4459,4460,4469,4470,4471,4472,5699,')}}
    {{~set 'PerishB' 'Loot: Perish'}}
    {{~set 'UnsortedB' 'Loot: Unsorted'}}
    {{#items E.S @root.Data.SourceB}}
    {{#test Id in @root.Data.OreL}}{{~move this @root.E.S @root.Data.OreB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.MedsL}}{{~move this @root.E.S @root.Data.MedsB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.IngotL}}{{~move this @root.E.S @root.Data.IngotB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.HandL}}{{~move this @root.E.S @root.Data.HandB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.PerishL}}{{~move this @root.E.S @root.Data.PerishB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.AmmoL}}{{~move this @root.E.S @root.Data.AmmoB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.WeaponL}}{{~move this @root.E.S @root.Data.WeaponB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.DeviceL}}{{~move this @root.E.S @root.Data.DeviceB}}{{/move}}{{/test}}
    {{#test Id in @root.Data.BlockL}}{{~move this @root.E.S @root.Data.BlockB}}{{/move}}{{/test}}
    {{~move this @root.E.S @root.Data.UnsortedB}}{{/move}}{{Name}} {{count}}
    {{/items}}
    {{/test}}
    
    make the PerishB a Fridge :)
     
    #693
  14. Blood Cloud

    Blood Cloud Ensign

    Joined:
    Sep 7, 2022
    Messages:
    10
    Likes Received:
    0
    Thanks .
    I only looked at the code with one eye and I saw a get/set on Custom name in ContainerSource.cs (but thats for something different i assume)

    and a stern :rolleyes: for Eleon ...
     
    #694
  15. bbk.3164

    bbk.3164 Commander

    Joined:
    May 17, 2016
    Messages:
    235
    Likes Received:
    88
    1) The "Damage" line does not work (!)
    i damage the block, but this line DOES NOT CHANGE its value (!) :(

    2) how to add parameter "Energy (power)" ??
    (amount of energy consumed per structure)

    [​IMG]
     
    #695
    Last edited: Mar 26, 2023
  16. bbk.3164

    bbk.3164 Commander

    Joined:
    May 17, 2016
    Messages:
    235
    Likes Received:
    88
    There were questions:
    1) Need detailed instructions - HOW TO CREATE A GARDEN WITH A GARDENER FROM SCRATCH?! (how to set zero anchor point correctly?!)
    2) what is the size of the garden??? I noticed that in the Test Base - if you install more hydroponics cells - then they DO NOT HAVE (!) only those hydroponics that are close to the gardener (!)


    because in the video - turn on subtitles and translate them - it's very difficult to understand! :(
    Please - make a text instruction :)
     
    #696
    Last edited: Mar 27, 2023
  17. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    If you search for "script" in the Steamworkshop you will find many CVs, bases etc. that either use or explain this. There you will find many ideas and templates.
     
    #697
  18. bbk.3164

    bbk.3164 Commander

    Joined:
    May 17, 2016
    Messages:
    235
    Likes Received:
    88
    Why are you sending me away to search for many scenarios that need to be searched for many months ?!
    Just create a short text step-by-step instruction - what and how to do?!
    Because I took YOUR demo ship and made a separate garden on it, BUT THE SCRIPT DOES NOT WORK, because I can't understand - HOW CORRECTLY assign the range of the garden ?! (Which of the 1-4 sides should be the "starting point of the garden" ??!!

    [​IMG]

    ... and IF I want to make 2-5 garden zones, with a separate gardener - then HOW do I need to rename all devices and screens so that the script continues to work correctly ?!

    Another question - HOW to add a "comment" to the code??
    I know from another language that a comment is denoted like this:
    //-- comment text
    but HOW is it done in c++???
     
    #698
  19. bbk.3164

    bbk.3164 Commander

    Joined:
    May 17, 2016
    Messages:
    235
    Likes Received:
    88
    @ASTIC, I made a long garden on your demo ship ... just for YOUR garden - added another x20 garden cells ... checked - EVERYTHING WORKS CORRECT (!)
    then 1 YOUR plant - killed to check the collection of dead plants ...
    The result - the dead plant was NOT REMOVED (!)
    But ripe sprouts - normally gathered (!)
    Then I COMPLETELY TRANSFER all components of the garden to another place (it's a gardener, screens, containers) ... harvesting a ripe crop FROM YOUR ORIGINAL GARDEN where the "dead plant" was left = WAS NORMAL (!)
    BUT == when I specified the NEW coordinates of the garden that had the dead plant == THEN THE SCRIPT DID NOT WORK (!)
    I don't know why (!) Perhaps - a dead plant is BLOCKING the harvest ??????
    ... I tried to CHANGE the COORDINATES of the garden range (in my previous message - on the screen == points 1-2-3-4 (!)
    ... but the harvest WAS NOT (!) :(
    ... then I REMOVED the dead plant from the new garden, ...... AND THE SCRIPT STARTED WORKING CORRECTLY (!)
    Why is that ????????
     
    #699
    Last edited: Mar 27, 2023
  20. bbk.3164

    bbk.3164 Commander

    Joined:
    May 17, 2016
    Messages:
    235
    Likes Received:
    88
    @ASTIC please tell - HOW to get the value of "energy consumption" (power) ???
     
    #700

Share This Page