[MOD EXT] Empyrion Scripting - Scripts

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

  1. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,071
    Likes Received:
    729
    I work on a solution with a new method

    Code:
    ...
    else if (items.Count < root.GetMaxSlots(container.Id))
    ...
     
    #921
  2. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,071
    Likes Received:
    729
    https://github.com/GitHub-TC/EmpyrionScripting?tab=readme-ov-file#savegame-scripts
    and examples
    https://github.com/GitHub-TC/EmpyrionScripting-Collection
     
    #922
  3. giruvegan

    giruvegan Ensign

    Joined:
    Oct 14, 2024
    Messages:
    2
    Likes Received:
    0
    ***Fixed - IGNORE***

    --> I had the wrong directory for adding my 'testscript.cs' and it didn't click the script had to be created for each save file....
    I should have used '[EGS]\Saves\Games\[save name]\Mods\EmpyrionScripting\Scripts'

    Hi, I'm looking for what I need to change to make CargoTeleporter work. Other scripts which do not modify container contents work, so I know I am referencing the correct entity and can set scripts up etc.

    CargoTeleporter as EmpyrionScripting-Collection/Scripts/CargoTeleporter.cs at master · GitHub-TC/EmpyrionScripting-Collection · GitHub doesn't function for me on single player. I have amended `Configuration.json` in `...\Empyrion - Galactic Survival\Content\Mods\EmpyrionScripting` to `"CsScriptsAllowedFor": "SaveGame",` and have spent about 2 hours now trying to get various things to work. I'm assuming this functionality still works and I'm just lost?
     
    #923
    Last edited: Oct 29, 2024 at 10:03 PM
  4. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,071
    Likes Received:
    729
    CargoTeleport and RE2 with the slot count of 128 not work from scratch at the moment, i'm on it ;-)
     
    #924
  5. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,071
    Likes Received:
    729
    #925
    giruvegan and me777 like this.
  6. giruvegan

    giruvegan Ensign

    Joined:
    Oct 14, 2024
    Messages:
    2
    Likes Received:
    0
    If you get this working, could you post the code? I can't for the life of me work out what needs to change. I have virtually no C# experience, I'd appreciate understanding where I went wrong;

    here's what I have which doesn't work:
    Code:
    
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Eleon.Modding;
    using EmpyrionScripting.CustomHelpers;
    using EmpyrionScripting.DataWrapper;
    using EmpyrionScripting.Interface;
    using Newtonsoft.Json;
    
    public class ModMain
    {
        public static void Main(IScriptModData rootObject)
        {
            if (!(rootObject is IScriptSaveGameRootData root)) return;
            if (root.E.Faction.Id == 0) return;
    
    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" +
                    //""));
                }
    
     
    #926

Share This Page