[MOD EXT] Empyrion Scripting - Scripts

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

  1. MrGReaper

    MrGReaper Lieutenant

    Joined:
    Jun 27, 2015
    Messages:
    61
    Likes Received:
    13
    At work so I can not load up the game at mo but will take a look at that later, thank you.

    I am using the EmpyrionScripting.Examples.csproj on my work laptop to create a script ready for when I get home. Ids doesnt seem to be a valid option for that however.... CsRoot.Root.Ids is....

    Can I check if the following would Move the item if the items name matched one of the entries in the configuration items Ingot array?


    Code:
                var sItems = CsRoot.Items(E.S, "A1SortingBox");
                string temp = "";
    
              
    
                foreach (var item in sItems)
                {
    
                    if (CsRoot.Root.Ids["Ingot"].Contains(item.Name))
                    {
                        var toMove = CsRoot.Move(item, E.S, "*Crafting*");
                    }
    }
    The IDE is showing it as good...but thats not always the case, so wanted to double check lol
    [​IMG]


    ----------------------EDIT------------------------

    Ok the as yet completly untested script (which the IDE says is OK.....will test after work):

    Code:
    var infoOutLcds = CsRoot.GetDevices<ILcd>(CsRoot.Devices(E.S, "DaveNewSort"));
                if (infoOutLcds.Length == 0)
                {
                    return;
                }
    
                int[] FuelAir = { 4159, 4176, 4177, 4186, 4314, 4335, 4336, 4421, 6009 };
                int[] Commodities = { 4344, 4347, 4366, 4367, 5102, 5103, 5106, 5111, 5112, 5115, 5913, 5914, 5916, 5917, 7514, 7515, 997805401, 558, 5925, 5924, 5926, 5911 };
                int[] crap = { 4107, 4135, 4348, 4349, 4351, 4352, 4353, 4354, 4355, 4356, 4429, 2179, 5932, 5933, 1485, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394 };
    
                var sItems = CsRoot.Items(E.S, "A1SortingBox");
                string temp = "";
    
                
    
                foreach (var item in sItems)
                {
                    if (crap.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var craplist = CsRoot.Move(item, E.S, "*crapBox*");
                        continue;
                    }
    
                    if (FuelAir.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var fuel = CsRoot.Move(item, E.S, "*SpareFuel*");
                        continue;
                    }
    
                    if (Commodities.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var Commoditieslist = CsRoot.Move(item, E.S, "*Commodities*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Ore"].Contains(item.Name))
                    {
                        if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre")
                        {
                            CsRoot.Move(item, E.S, "*Crafting*");
                        }
                        else { CsRoot.Move(item, E.S, "*Ore Box*"); }
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["OreFurnace"].Contains(item.Name))
                    {
                        if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre")
                        {
                            CsRoot.Move(item, E.S, "*Crafting*");
                        }
                        else { CsRoot.Move(item, E.S, "*Ore Box*"); }
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Ingot"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["BlockL"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Blocks Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["BlockS"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Blocks Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Medic"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Medical*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Food"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Food*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Sprout"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Plant*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Tools"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Tools*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["ArmorMod"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Boosts*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["DeviceL"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Devices Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["DeviceS"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Devices Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponPlayer"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Weapons Box*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponHV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*HV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponSV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*SV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponBA"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Base Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponCV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*CV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoPlayer"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Hand*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoHV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoSV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoCV"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoBA"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Armor"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Armour*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Deconstruct"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Deconstruct*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponPlayerUpgrades"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Upgrades*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["WeaponPlayerEpic"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Weapons Advanced*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Deco"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Decoration*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["DataPads"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Datapads*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoAllEnergy"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoAllProjectile"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["AmmoAllRocket"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["Components"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["EdenComponents"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    //the food in below should already be removed
                    if (CsRoot.Root.Ids["Ingredient"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["IngredientBasic"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["IngredientExtra"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.Ids["IngredientExtraMod"].Contains(item.Name))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
                    var miList = CsRoot.Move(item, E.S, "*DestBox*");
                    miList.ForEach(mi =>
                    Console.WriteLine(
                    $"{mi.Id}\n" +
                    $"{mi.Count}\n" +
                    $"\n" +
                    ""));
                }
     
    #761
    Last edited: Aug 29, 2023
    Xyberwolf likes this.
  2. Xyberwolf

    Xyberwolf Ensign

    Joined:
    Jan 29, 2017
    Messages:
    5
    Likes Received:
    1
    It did help!! Thank you! Now that I can call it, I'm off to more coding! :)
     
    #762
    MrGReaper likes this.
  3. MrGReaper

    MrGReaper Lieutenant

    Joined:
    Jun 27, 2015
    Messages:
    61
    Likes Received:
    13
    Very Tired but here is my now working script (its a savegame script):


    Code:
                var infoOutLcds = CsRoot.GetDevices<ILcd>(CsRoot.Devices(E.S, "DaveNewSort"));           
                if (infoOutLcds.Length == 0)
                {
                    return;
                }
    
                int[] FuelAir = { 4159, 4176, 4177, 4186, 4314, 4335, 4336, 4421, 6009 };
                int[] Commodities = { 4344, 4347, 4366, 4367, 5102, 5103, 5106, 5111, 5112, 5115, 5913, 5914, 5916, 5917, 7514, 7515, 997805401, 558, 5925, 5924, 5926, 5911 };
                int[] crap = { 4107, 4135, 4348, 4349, 4351, 4352, 4353, 4354, 4355, 4356, 4429, 2179, 5932, 5933, 1485, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394 };
    
                var sItems = CsRoot.Items(E.S, "A1SortingBox");
                string temp = "";
    
    
    
                foreach (var item in sItems)
                {
                    //foreach (ILcd lcd in infoOutLcds)
                    //    {
                    //        temp = lcd.GetText();
                    //        lcd.SetText($"{item.Name} (ID: {item.Id}) (Key: {item.Key}) x {item.Count}{Environment.NewLine} {temp} ");
                    //    }
                    if (crap.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var craplist = CsRoot.Move(item, E.S, "*crapBox*");
                        continue;
                    }
    
                    if (FuelAir.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var fuel = CsRoot.Move(item, E.S, "*SpareFuel*");
                        continue;
                    }
    
                    if (Commodities.Contains(item.Id))
                    {
                        foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                        var Commoditieslist = CsRoot.Move(item, E.S, "*Commodities*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Ore"].Contains(item.Key))
                    {
                        if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre")
                        {
                            var ore = CsRoot.Move(item, E.S, "*Crafting*");
                        }
                        else { var ore2 = CsRoot.Move(item, E.S, "*Ore Box*"); }
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["OreFurnace"].Contains(item.Key))
                    {
                        if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre")
                        {
                            var orefurnace = CsRoot.Move(item, E.S, "*Crafting*");
                        }
                        else { var ore2 = CsRoot.Move(item, E.S, "*Ore Box*"); }
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Ingot"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["BlockL"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Blocks Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["BlockS"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Blocks Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Medic"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Medical*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Food"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Food*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Sprout"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Plant*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Tools"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Tools*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["ArmorMod"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Boosts*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["DeviceL"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Devices Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["DeviceS"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Devices Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponPlayer"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Weapons Box*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponHV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*HV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponSV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*SV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponBA"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Base Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponCV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*CV Weapons*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoPlayer"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Hand*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoHV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoSV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Small*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoCV"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoBA"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Large*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Armor"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Armour*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Deconstruct"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Deconstruct*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponPlayerUpgrades"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Upgrades*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["WeaponPlayerEpic"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Weapons Advanced*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Deco"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Decoration*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["DataPads"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Datapads*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoAllEnergy"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoAllProjectile"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["AmmoAllRocket"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Ammo Misc*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["Components"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["EdenComponents"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    //the food in below should already be removed
                    if (CsRoot.Root.PlainIds["Ingredient"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["IngredientBasic"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["IngredientExtra"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
    
                    if (CsRoot.Root.PlainIds["IngredientExtraMod"].Contains(item.Key))
                    {
                        CsRoot.Move(item, E.S, "*Crafting*");
                        continue;
                    }
                    foreach (ILcd lcd in infoOutLcds)
                        {
                            temp = lcd.GetText();
                            lcd.SetText($"{item.Name} (ID: {item.Id}) (Key: {item.Key}) x {item.Count}{Environment.NewLine} {temp} ");
                        }
                    var miList = CsRoot.Move(item, E.S, "*DestBox*");
                    //miList.ForEach(mi =>
                    //Console.WriteLine(
                    //$"{mi.Id}\n" +
                    //$"{mi.Count}\n" +
                    //$"\n" +
                    //""));
                }
    I am sending items not in the config file to an lcd so i can get the "item.Key" and add it to the relevent list (hoping those lists do not get reset)
     
    #763
  4. MrGReaper

    MrGReaper Lieutenant

    Joined:
    Jun 27, 2015
    Messages:
    61
    Likes Received:
    13
    I dont know if this will help but when sorting out my script I found Ids seemed to simplify the response, so for example instead of returning 4319, 4320, 4321, 4322, 4323, etc it would return 43219-4323 (as shown in Astic's image on the last page). This made it hard to check to see if a list contained a specific ID, cant really check if it contains 4320 for example. I also hit an issue that it would contain 431 as 4319 has 431 in it. searching for ","+item.Id+"," (where item.Id would be 431) would solve the latter but not the former. using PlainIds instead of Ids returned the internal names exactly how they are in the config lists..... much better to search.
    Item.Id gives you the items ID
    Item.Name gives you the name (not the same as the plain ID)
    Item.Key gives you the items PlainId

    In the code I posted above I output anything it fails to find onto a LCD panel (for me its a fair bit... some scenario stuff but Salt wasnt in the configs.....odd.... so i can add the Key(plainID) to the config. changes to the config lists are immediate and do not need a server restart. I am hoping they do not get over written and I am hoping i can add my own sections.

    I use this line:
    Code:
    lcd.SetText($"{item.Name} (ID: {item.Id}) (Key: {item.Key}) x {item.Count}{Environment.NewLine} {temp} ");
    For anyone not familiar with c# that may look taunting (trust me the LUA? HBBA? code on the github looks insane to me lol) but its pretty simple. between the " marks is a string, the $ before them tells it that I am going to put values direct into it, bits inside it in {}'s are where I am grabing a value. The temp value is what is already on the screen, thats grabbed further up, just so we get a list..... I need to add some code that blanks it if the lines got two many..... thats another day issue.

    Note to others:

    Some c# explained for my script (this may help, some, may come over as simplistic to others)

    // is for commenting out a line, allows you to add notes or remove test code.

    foreeach: This is a simple loop,
    Code:
    foreach (var item in sItems)
    Is saying, do a loop for each entry in the sItems list and call the entry "item" as you go through the list. The sItems.
    it checks each item with if statements, lets take one from the code and add comments to it:

    Code:
    if (CsRoot.Root.PlainIds["Ore"].Contains(item.Key)) //check to see if the Ore list in configuration contains the plainID (or Key) of the item were looking at. if it does do the following
                    {
                        if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre") // is it an ore we use for crafting? that shouldnt go to the furnace so I check for the specific name...I made a mistake her in my code and it should be .Key not .Name, left it the same though
                        {
                            var ore = CsRoot.Move(item, E.S, "*Crafting*"); //move the item to a box with "Crafting" in its name. thats the *'s allowing stuff before and after.
                        }
                        else { var ore2 = CsRoot.Move(item, E.S, "*Ore Box*"); } //if its in that Ore list and not matching the If above then move it to a box with "Ore Box" in its name
                        continue;  //we are done on this item, go to the next, skip the rest of the loop.
                    }
    continue: this tells a loop to finish with the item its on and move onto the next one.
    break: not used in my code but would tell a loop to stop fully, dont do any more items... break out of the loop
    return: This is used near the start of my script....save game scripts are running all the time on all grids, I create a list of LCD screens named "DaveNewSort", I then check that list is not 0, ie, I check to see if there is atleast one, if there is not then I "return" out of the script.
    Yeah theres a few minor bugs, hey I finished it at 0400 after 2 or 3 hours of cursing at it.

    Dont know if any of this will help anyone but figured i would take the time to jot it down.

    If anyone wishes to return the favour. I would love to know how to do the salvaging script in c# really cant make head nor tales of that script and would love to make one that would salvage certain named blocks and retrieve others...for that i kind of need to do it in c#
     
    #764
  5. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Ich habe Version 1.10.3. geupdatet, die alten Spielstände laufen.
    Nun habe ich ein neues Angefangen und der Cargo Teleporter wie auch das Zerlegescript( ich nutze nur das Recycle Script) laufen nicht mehr.
    Geändert habe ich nichts, nur neues Game angefangen. Ist so etwas bekannt ?
     
    #765
  6. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Die Savegame Scripts, wie z.B. CargoTeleport liegen, wie der Name schon andeutet im Savegameverzeichnis - du muss die also bei einem neuen Spiel vom alten Savegame rüberkopieren
     
    #766
  7. BugiTree

    BugiTree Ensign

    Joined:
    Oct 3, 2022
    Messages:
    24
    Likes Received:
    0
    Thx, jetzt geht es...Ordnersachen...:(:oops::thumpUp:
     
    #767
  8. Кука Синкай

    Кука Синкай Ensign

    Joined:
    Sep 6, 2023
    Messages:
    4
    Likes Received:
    0
    Good time of the day to all,
    I would like to ask a question about "blocks itteration". Namely, in the code like:
    ```
    {{~#blocks @root.E.S @root.Data.MinX @root.Data.MinY @root.Data.MinZ @root.Data.MaxY @root.Data.MaxY @root.Data.MaxZ}}
    {{~#each .}}
    Type: {{.blockType}} at {{.Position}} named as {{i18n .Id}}
    {{/each}}
    {{/blocks}}
    ```
    I became an empty array as a return value.
    Looking into docs and git, have found that `blocks` stores the date in a cache for some other commands... So the question - how to use it then?
    The main goal was to itterate through all the blocks of the entity's structure (and possibly filter them to get only structural blocks in the array by type).
    Does someone know a way to do this?
    P.S. Have tryed `devicesoftype` also with no success...
     
    #768
  9. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    It works...

    [​IMG]

    Maybe you not "set" the Max/Min values correct or your double MaxY is the reason
     
    #769
  10. Кука Синкай

    Кука Синкай Ensign

    Joined:
    Sep 6, 2023
    Messages:
    4
    Likes Received:
    0
    Hallo, ASTIC... Eigentlich, "double MinY" ist ein Tippfehler. Der Code selbst ist in Wirklichkeit korrekt.
    Die Koordinaten werden anhand der minimalen und maximalen Position des Objekts bestimmt.
    Und zwar als:
    {{~set 'MinX' @root.E.S.MinPos.X}}
    {{~set 'MinY' @root.E.S.MinPos.Y}}

    ... u.s.w.
    Ich versuche es nochmal ueberprufen. Tja, und, warscheinlich, MOD selbst vom GIT neuladen. Mal sehen, wo ich das Fehler gemacht. Danke fuer Tip.
     
    #770
  11. Кука Синкай

    Кука Синкай Ensign

    Joined:
    Sep 6, 2023
    Messages:
    4
    Likes Received:
    0
    Good time of the day.
    I have tried to recheck all the code - no syntax errors or something like mistyping. Have tried to use "Creative Mode" with MOD. And "Dedicated server" with MOD. Have deleted and reinstalled MOD.
    Have no success. The picture and code are bellow. (I have tried also cut only `blocks` helper and set coords there "by hands"...) :(
    Note: Was unable to insert picture here... Just as a commetn - works all except `blocks listing`...
    Code:
    {{~use @root.E.S}}
    Structure:
    1. Damage level - {{DamageLevel}}
    2. Is powered: - {{IsPowerd}}
    3. Blocks count - {{BlockCount}}
    4. Shield level - {{ShieldLevel}}
    5. Total mass - {{TotalMass}}
    {{~set 'MinX' MinPos.X}}
    {{~set 'MinY' MinPos.Y}}
    {{~set 'MinZ' MinPos.Z}}
    {{~set 'MaxX' MaxPos.X}}
    {{~set 'MaxY' MaxPos.Y}}
    {{~set 'MaxZ' MaxPos.Z}}
    {{/use}}
    {{~block @root.E.S 2 129 2}}
    Single Block: {{.Position}} - ID:{{.id}} - Type: {{.blockType}}
    {{i18n .blockType "English"}}/{{i18n .blockType}}
    {{/block}}
    {{~use @root.Data}}
    <color=red>Try to iterate blocks from {{MinX}}:{{MinY}}:{{MinZ}} to {{MaxX}}:{{MaxY}}:{{MaxZ}}:</color><br>
    {{/use}}
    {{scroll 5 1}}
    {{~#blocks @root.E.S @root.Data.MinX @root.Data.MinY @root.Data.MinZ @root.Data.MaxX @root.Data.MaxY @root.Data.MaxZ}}
    {{~#each .}}
    Type: {{.blockType}} at {{.Position}} named as {{.Id}}
    {{/each}}
    {{/blocks}}
    {{/scroll}}
    <br><color=red>End of iteration try.</color>
    And now I wonder - what is/are the difference(s) between my approach and your one? Any ideas?
    P.S. Man kann mir auch auf Deutsch schreiben (antworten), wenn es bequemer waere...
     
    #771
  12. Кука Синкай

    Кука Синкай Ensign

    Joined:
    Sep 6, 2023
    Messages:
    4
    Likes Received:
    0
    Actually, I see...
    MinPos & MaxPos as I now understand should not be used as corner coords either...
    Why? - it is another question...
    P.S. Just FYI - each new created structure has a core with coordinates (0;128;0). No matter what is a type of structure created... So in my code one should use `calc` | `math` helpers to be sure it properly works.
    P.P.S. More over. Then the core is moved, then coords taken from MinPos & MaxPos will be calculated related to the new core position, BUT! The blocks coords will stay the same as with the old core.
    Thus, to calculate the "area of effect", one should first take the position of new core and then `calc` it to Min|Max values - wrapping the area in this way.
     
    #772
    Last edited: Sep 11, 2023
  13. Xyberwolf

    Xyberwolf Ensign

    Joined:
    Jan 29, 2017
    Messages:
    5
    Likes Received:
    1
    Hello fellow coders!
    I have a quick question. I think I'm close, but can anyone give me an example of turning on and off a small constructor?
    (If 'OreInput' has leq 5 units of ore, turn off 'SmallConstructor1', else turn 'SmallConstructor1' on.)
    I don't think I have all the information on the setactive command. Thank you in advance!!
     
    #773
  14. TOFFEL

    TOFFEL Ensign

    Joined:
    Oct 13, 2023
    Messages:
    8
    Likes Received:
    0
    Hello,

    why is #test not working when the variable is the result of a (calc) function? With calc #test will compare strings not nunmbers.

    In both examples No1 is -9 and No2 is 0

    Code:
    working (Result = smaller):
    {{~set 'No1' -9}}
    {{~set 'No2' 0}}
    {{@root.Data.No1}} {{#test @root.Data.No1 le @root.Data.No2}}is smaller{{else}}is greater{{/test}}
    
    not working (Result = greater):
    {{~set 'No1' (calc 1 '-' 10)}}
    {{~set 'No2' 0}}
    {{@root.Data.No1}} {{#test @root.Data.No1 le @root.Data.No2}}is smaller{{else}}is greater{{/test}}
    
     
    #774
  15. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    HBS can onloy return a string value from '(calc 1 '-' 10)' in the parameter stream only block commands with a # and an {{/ end can handle direct objects as int, bool, array etc.
     
    #775
  16. TOFFEL

    TOFFEL Ensign

    Joined:
    Oct 13, 2023
    Messages:
    8
    Likes Received:
    0
    ASTIC, thanks for your reply. So I have to add something after the calc function. But how?
    Is there a way to convert variable No1 to a number ?
    {{~set 'No1' (calc 1 '-' 10)}} => is a String but I want a Number

    I want to #test if an item in a box is lower than 10. The problem is, I want to divide "Count" by 4 and compare that result.
    {{~set 'No1' (calc Count '/' 4)}}
    {{#test @root.Data.No1 le 10}}Warning: is smaller{{else}}is greater{{/test}}
     
    #776
  17. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Code:
    {{#math Count '/' 4}}
    {{set 'No1' this}}
    {{/math}}
    to store a number in 'No1'
    or
    Code:
    {{#test 10 'ge' @root.Data.No1}}
    ....
    because 'test' use the type of the left part - here an int for the comparison
     
    #777
  18. johnny1972

    johnny1972 Ensign

    Joined:
    Jul 11, 2019
    Messages:
    9
    Likes Received:
    0
    Does the harvest script work in SP?
     
    #778
  19. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Possible, but unfortunately some functions of the API do not work in the SP i.e. just try it out
     
    #779
  20. johnny1972

    johnny1972 Ensign

    Joined:
    Jul 11, 2019
    Messages:
    9
    Likes Received:
    0
    I have for the last 2 weeks. The others work just fine. Is there a way to setup a teleporter script to work with bases.? Or do I need to setup a MP private sever.
     
    #780

Share This Page