[MOD EXT] Empyrion Scripting - Scripts

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

  1. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    I am trying to do something similar to @Mycroft_Groks I have a carrier and I want to pull Materials from 1 docked ship and put it in a different docked ship. I can pull from a docked ship and stock the carrier but I can't put the stuff in a container on the other docked ship. Here is my code.

    Code:
    {{!Constructor Feed 1}}
    {{#each @root.E.S.DockedE}}
    {{#items S 'Box-*'}}
    {{~set 'ConsFeed1HYP' ''}}
    {{~set 'Amount' ''}}
    
    {{#test Id in '4296,4302,4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4331,4333,4338,4360,4376,4377,4401,4445'}}
    {{~set 'ConsFeed1HYP' '*TInput*'}}
    {{~set 'Amount' 2000}}
    {{/test}}
    
    {{#test Id in '4339,4340,4341,4346,4357,4362,4366,4444'}}
    {{~set 'ConsFeed1HYP' '*TInput*'}}
    {{~set 'Amount' 400}}
    {{/test}}
    
    {{#ok @root.Data.ConsFeed1HYP}}
    {{#move . ../../../S @root.Data.ConsFeed1HYP @root.Data.Amount}}
    {{datetime}}
    {{Source}} -> {{Destination}}
    {{format Count '{0,5}'}}:
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/each}}
    Just like him I'm pretty sure my issue is in the
    Code:
     {{#move . ../../../S @root.Data.ConsFeed1HYP @root.Data.Amount}}
     
    #581
  2. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    That's outta the Hyperion, right?
     
    #582
  3. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    That would make since! I wondered why it said ConsFeed1HYP never knew what the hyp was. I pulled it out of my factions base.
     
    #583
  4. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    I have simplified the code I am modifying down a little. And I'll explain what I'm trying to accomplish. I use the Aurora Carrier or the Helios Carrier. My goal is to be able to have a Cargo module to store all cargo on that Docks to the Carrier and then a Module that does production as a different module docked to the Carrier.

    I want to Feed materials from the Cargo Module to the Production module in a set amount (IE 2oo0 of each ingot, 500 of each component). I found some code in my base that does this around the base. The code is from the Hyperion ship available on steam workshop. So far I have gotten the code to pull from all the containers on my Cargo Module with the name 'Box-*' and put them into the box called '*InputTest*' on the carrier but I haven't been able to get the move command to target my docked Production Module. I have tried inserting the ship id but again I think I'm doing something wrong.

    I also tried expanding the script to look at all entities in the area and pull from their Box- containers and put this script on the docked ship. again I'm sure I didn't do it right.

    Any help would be appreciated. I am no programmer but I'm minoring in computer science so if you can provide any explanation as to what I need to try or what I'm doing wrong please let me know.

    Code:
    {{!Constructor Feed 1}}
    {{#each E.S.DockedE}}
    {{#items S 'Box-*'}}
    {{~set 'ConsFeed1' ''}}
    {{~set 'Amount' ''}}
    
    {{#test Id in '4296,4320'}}
    {{~set 'ConsFeed1' '*InputTest*'}}
    {{~set 'Amount' 4}}
    {{/test}}
    
    {{#ok @root.Data.ConsFeed1}}
    {{#move ../. @root.E.S @root.Data.ConsFeed1 @root.Data.Amount}}
    {{datetime}}
    {{Source}} -> {{Destination}} 
    {{format Count '{0,5}'}}:
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/each}}
    
    In the Move command line what is the purpose of ../. I know the first part of the command is the structure but I thought that's what the @root.E.S. was. Its the structure that i'm targeting right?
     
    #584
  5. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Seems to be ok, but you have to name your Box 'InputTest' or 'xyzInputTest123' not '*InputTest*' because '*' ist the wildcard character for the name search.
     
    #585
  6. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    The container is named InputTest. The script works except it targets the Carrier container InputTest but not the one on the docked ship. I read earlier where the move command needs a specific target. I'm thinking @root.E.S is telling the script to look at the current structure instead of looking for a docked ship.

    If I wanted to target a specific ship ID would I just replace @root.E.S with the ID of the ship or would i have to use EntityByID or something like that to target it.
     
    #586
  7. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Last, it needs the entity as an object
     
    #587
  8. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    My Brain hurts lol...

    So I threw {{Name}} into the script after {{/Test}} and before the {{ok}} and it returned the list of items. So I changed it to {{../Name}} and it returns the name of the docked Cargo ship. I tried adding ../../ and it gives an error.

    From this I think that in the part of the code where I am doing the {{move}} command the loop(?) I am in is set to the Docked Cargo Ship.

    I read through the discussion at
    [MOD EXT] Empyrion Scripting - Discussions | Empyrion – Galactic Survival - Community Forums (empyriononline.com)
    And so I tried using {{~set 'Ship' S}} at the beginning to name the ship I am targeting. Then I realized this wasn't going to have the effect I wanted. So at this point I'm trying to figure out how to target a specific ship ID.

    I did the simple script of
    Code:
    {{entitybyid 14847150}}
    ____{{Name}}_____
    {{/entitybyid}}
    
    It returns the name of the ship I want to target with my move. I'm just not sure how to use this to help achieve my goal.

    If I did something like
    Code:
    {{entitybyid 14847150}}
    {{~set 'Ship' S}}
    {{/entitybyid}}
    
    at the beginning of the code and then changed my {{move}} to something like
    Code:
    {{#move @root.Data.Ship @root.Data.ConsFeed1 @root.Data.Amount}}
    Would that work?

    P.S. I'm trying that now to see if i get an error ....

    P.S. Yea that didn't work. It does save the ship name but there is still an error of some kind but it doesn't show an output on the LCD.
     
    #588
    Last edited: Dec 16, 2022
  9. Drazzig

    Drazzig Ensign

    Joined:
    Dec 11, 2022
    Messages:
    6
    Likes Received:
    0
    Ok I think I found a better way. Instead of using the Carrier (Parent) ship to move cargo between two different docked ships. I used the entities by id to move the cargo to the Production Module from the Cargo Module. With just a very small change to the original code.

    Code:
    {{!Constructor Feed 1}}
    {{entitybyid 14847150}}
    Pulling Materials from 
    
    {{Name}} - {{Id}}
    {{#items S 'Box-*'}}
    {{~set 'ConsFeed1' ''}}
    {{~set 'Amount' ''}}
    
    {{#test Id in '4296,4320'}}
    {{~set 'ConsFeed1' '*InputTest*'}}
    {{~set 'Amount' 4}}
    {{/test}}
    
    {{#ok @root.Data.ConsFeed1}}
    {{#move ../. @root.E.S @root.Data.ConsFeed1 @root.Data.Amount}}
    {{datetime}}
    {{Source}} -> {{Destination}} 
    {{format Count '{0,5}'}}:
    {{/move}}
    {{/ok}}
    {{/items}}
    {{/each}}
    {{/entitybyid}}
    
     
    #589
  10. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    The server I admin for is having issues getting RE 1.9 to start your scripting mod. We have the files loaded, but they are not activating. Ideas? We are using the .zip from 2 weeks ago that is the current on your github.
     
    #590
  11. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    #591
    Mycroft_Groks likes this.
  12. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    Thank-you, sir. I can confirm that we are now up and running.
     
    #592
    ASTIC likes this.
  13. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    so....this script moves the contents of one docked CV to another docked CV? am I understanding that right? I'm attempting to get items from my CV to a docked ship. All I can get working is the script I modded from a post on this thread. See the previous page for my post.
     
    #593
  14. wolffstarr

    wolffstarr Ensign

    Joined:
    Oct 17, 2020
    Messages:
    5
    Likes Received:
    8
    I'm assuming that my google-fu is simply failing me on this point, but I've spent several hours over the space of a week now trying to find this and failing. Is there a script that will basically loot all the containers in a POI for you?

    Basically, I want to take over a POI, drop my core in, and have a script go through all of the containers and loot everything out of them and into a container on my CV. I can't imagine that this isn't possible (and I'd be shocked if it's not done regularly, given the number of containers that are usually in POIs), given all the other inventory stuff that can be done, but I'm terrible at writing scripts from scratch and I can't find one that does anything quite like this to try and modify.

    I'm not even looking for special loot containers; just the ones that can be accessed via the Logistics menus, so I don't have to scroll through the list one by one in order to loot the structure. I've tried searching this thread, but the closest I get is moving stuff from a named container on one vessel to another that it's docked to, and I want to avoid container rename as much as possible for this.
     
    #594
  15. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    I tryed this once and the script could not find annything in the ex-POI. (just trying to list everything, the exact same script worked with player built structures.)
    There must be some post of me asking if this is intentional and ASTIC said must be a game bug.
    But that was like 1 game version ago, might work now, did not test again...

    *edit/update*

    put a core in a space poi and testet:
    @root.E.S.items is empty
    #items @root.E.S '*' also is empty
    the containers show in #deviceoftype

    if i place a container and put something inside the former commands find only the contens of the new container.
     
    #595
    Last edited: Dec 27, 2022
  16. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    #596
    Last edited: Jan 1, 2023
  17. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    I haven't been able to get this working as well. Best I came up with, is to have three Decon options in my script; Recycle, Decon and Loot. The Loot only removes hull blocks and certain other blocks that I've selected based on Item IDs. This leaves any turret, container or Deco block that has inventory slots alone. I then need to go block by block and using the F menu, move the contents from the left-over containers. Not optimal, but it works.
     
    #597
    Last edited: Jan 1, 2023
  18. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Can I somehow figure out if the current ship is docked to a specific other ship (inverted dockedE)?
     
    #598
  19. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Little somthing I made, It displays content of ammo containers and distributes the ammo between them. Only really usefull if you got a few ammo controlers.
    Code:
    {{~#ok @root.CacheData.M}}
    <size=70%>{{~items E.S @root.cachedata.N}}
    {{Count}}<indent=40>{{Name}}</indent>
    {{~#move . @root.E.S @root.cachedata.N (calc Count '/' @root.CacheData.M 0)}}
    {{~/move}}
    {{~/items}}</size>
    {{~else}}
    else
    {{~set 'count' 0}}
    {{~devicesoftype E.S 'AmmoCntr'}}
    {{~#each .}}
    {{~set 'c' (calc @root.data.c '+' 1)}}
    {{~setcache 'N' (concat customname ',' @root.cachedata.N) }}
    {{~/each}}
    {{~/devicesoftype}}
    {{~setcache 'M' @root.data.c}}
    {{~/ok}}
    
     
    #599
    Last edited: Jan 4, 2023
  20. Mycroft_Groks

    Mycroft_Groks Lieutenant

    Joined:
    Aug 17, 2018
    Messages:
    51
    Likes Received:
    8
    I'm getting an error when I run this script and the switch is turned off. It works as intended when the switch is on.

    What I want to do is when the switch is on, all docked ships will move all items from their containers named '*OUTGOING*' to a container on the carrier labeled '*DUMPBOX*. That works as intended.

    What I can't get to work is when the switch is down, I want the carrier to empty it's containers named 'Trade' into a container on the same ship named '*OUTGOING*' so when the carrier is docked, it's contents can be emptied.

    When I try it, I get a "{{Items}} error Object Reference not set to an instance of an object".

    Code:
    <pos=0>◜</pos>       <color=red><u><b>SHODAN Core Systems</color></u></b><pos=188>◝</pos>
    <pos=0>◟</pos>            <i><size=125%>Automove cargo</size></i><pos=188>◞</pos></size>
    {{#getswitch @root.E.S 'CORE_Automove'}}
    {{#if SwitchState}}
    
    <color=green><b><u><align=center>Receive Mode Enabled</align></u></b></color>
    
    Scanning:
    {{scroll 5 1}}
    {{~#each @root.E.S.DockedE}}
    <indent=6>◉ <color=grey>{{Name}}</color></indent>
    {{#items S '*OUTGOING*'}}
    {{move this @root.E.S '*DUMP BOX*'}}
    {{/move}}
    {{/items}}
    {{/each}}
    {{/scroll}}
    
    {{else}}
    
    <size=175%><align=center><color=yellow><u>WARNING!!</u></size></color>
    <size=125%><color=red>Evacuation Mode Enabled!</color></size></align>
    
    {{#items E.S 'Trade*'}}
    {{#test Id leq 1000}}
    {{move this @root.E.S '*OUTGOING*' 100}}
    {{SourceE.Name}}:{{Source}}->
    {{~DestinationE.Name}}:{{Destination}}
    {{format Count '{0,5}'}} : {{i18n Id}}
    {{/move}}
    {{else}}
    {{move this @root.E.S '*OUTGOING*'}}
    {{SourceE.Name}}:{{Source}}->
    {{~DestinationE.Name}}:{{Destination}}
    {{format Count '{0,5}'}} : {{i18n Id}}
    {{/move}}
    {{/test}}
    {{/items}}
    {{/if}}{{/getswitch}}
    
     
    #600
    Last edited: Jan 6, 2023

Share This Page