I work on a solution with a new method Code: ... else if (items.Count < root.GetMaxSlots(container.Id)) ...
https://github.com/GitHub-TC/EmpyrionScripting?tab=readme-ov-file#savegame-scripts and examples https://github.com/GitHub-TC/EmpyrionScripting-Collection
***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?
EmpyrionScripting 13.4.0 https://github.com/GitHub-TC/EmpyrionScripting/releases/tag/13.4.0 LootListToSlotCount defines the property "MaxSlots" and "int GetMaxSlots(int blockType)" the default is 64 Code: "LootListToSlotCount": { "48": 128, "66": 128, "67": 64, "300": 128 }, @giruvegan @me777
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" + //"")); }
I havent had the time to re-learn how to setup the developer environment yet, the github for this mod is a wall of text that will take me some time to go through again...if memory serves i had to importa a project into visual studio to get assistance from the IDE. I get so little free time these days. That said the script i wrote required chests to be named accordingly for the items to be moved... and I can see i had some debug code in there. // is a comment out, so that last section should list the items as they are moved. Its also worth noting the ID's i have coded at the start may have changed. Assuming the api has not changed then each loop of the script is checking if the item Ids inside the box named A1SortingBox matched the list as it went down it... if it does that item is moved to the relevently named box... if it matched none of the liksts it is moved to the Destination box and the id for that item is put on a lcd so it can be looked at later and added to a local id check. The code looks daunting if your unfamilar with c# but its actually really simplistic. If i get time to remember how to setup a dev environment and get time to correct the script i will post it here. EDIT: It is also worth noting the script i shared is now very old and I should be considered a NOOB, hell i can not even find how you load a .cs script once its in the savegame folder lol* To load the script you need to name an lcd the same as the .cs file with out the .cs part (or so it seems, though my script errors and i know not why)
I put my old script into a file called daves.cs in the correct folder. I then named a lcd daves The lcd got the following error in its text field: Code: Microsoft.CodeAnalysis.Scripting.CompilationErrorException: (315,14): error CS1513: } expected at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.ThrowIfAnyCompilationErrors (Microsoft.CodeAnalysis.DiagnosticBag diagnostics, Microsoft.CodeAnalysis.DiagnosticFormatter formatter) [0x00065] in <6cf7fc429b4f4d0d940bd4471aba15db>:0 at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.CreateExecutor[T] (Microsoft.CodeAnalysis.Scripting.ScriptCompiler compiler, Microsoft.CodeAnalysis.Compilation compilation, System.Boolean emitDebugInformation, System.Threading.CancellationToken cancellationToken) [0x0001b] in <6cf7fc429b4f4d0d940bd4471aba15db>:0 at Microsoft.CodeAnalysis.Scripting.Script`1[T].GetExecutor (System.Threading.CancellationToken cancellationToken) [0x0002e] in <6cf7fc429b4f4d0d940bd4471aba15db>:0 at Microsoft.CodeAnalysis.Scripting.Script`1[T].RunAsync (System.Object globals, System.Func`2[T,TResult] catchException, System.Threading.CancellationToken cancellationToken) [0x0001b] in <6cf7fc429b4f4d0d940bd4471aba15db>:0 at EmpyrionScripting.CsCompiler.CsCompiler+<>c__DisplayClass49_0`1[T].<GetExec>b__2 (System.Object rootObject) [0x0018e] in <2ca20212a4ed43e3a1ae2925b2bfd684>:0 Not sure if its a me error or a script mod error? Edit.... it seems to be a change with the api. going right down to : Code: using System; using System.Linq; using System.Text; using Eleon.Modding; using EmpyrionScripting.Interface; 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; } } } Shows the error to be var infoOutLcds = ..... the error being An object reference is required for the non-static field, method, or property 'IScriptModData.CsRoot I am guessing we can no longer use var.... but i have no clue what it expects EDIT 2 OK NOW I AM STUCK. So i found the error... you now need to specify root so CsRoot becomes root.CsRoot and E.S becomes root.E.S I made the following changes to the script: 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 = root.CsRoot.GetDevices<ILcd>(root.CsRoot.Devices(root.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 = root.CsRoot.Items(root.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 (root.CsRoot.Root.PlainIds["Ore"].Contains(item.Key)) { if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre") { var ore = root.CsRoot.Move(item, root.E.S, "*Crafting*"); } else { var ore2 = root.CsRoot.Move(item, root.E.S, "*Ore Box*"); } continue; } if (root.CsRoot.Root.PlainIds["OreFurnace"].Contains(item.Key)) { if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre") { var orefurnace = root.CsRoot.Move(item, root.E.S, "*Crafting*"); } else { var ore2 = root.CsRoot.Move(item, root.E.S, "*Ore Box*"); } continue; } if (root.CsRoot.Root.PlainIds["Ingot"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["BlockL"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Blocks Large*"); continue; } if (root.CsRoot.Root.PlainIds["BlockS"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Blocks Small*"); continue; } if (root.CsRoot.Root.PlainIds["Medic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Medical*"); continue; } if (root.CsRoot.Root.PlainIds["Food"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Food*"); continue; } if (root.CsRoot.Root.PlainIds["Sprout"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Plant*"); continue; } if (root.CsRoot.Root.PlainIds["Tools"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Tools*"); continue; } if (root.CsRoot.Root.PlainIds["ArmorMod"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Boosts*"); continue; } if (root.CsRoot.Root.PlainIds["DeviceL"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Devices Large*"); continue; } if (root.CsRoot.Root.PlainIds["DeviceS"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Devices Small*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayer"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Weapons Box*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponHV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*HV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponSV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*SV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponBA"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Base Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponCV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*CV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoPlayer"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Hand*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoHV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Small*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoSV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Small*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoCV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Large*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoBA"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Large*"); continue; } if (root.CsRoot.Root.PlainIds["Armor"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Armour*"); continue; } if (root.CsRoot.Root.PlainIds["Deconstruct"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Deconstruct*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayerUpgrades"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Upgrades*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayerEpic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Weapons Advanced*"); continue; } if (root.CsRoot.Root.PlainIds["Deco"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Decoration*"); continue; } if (root.CsRoot.Root.PlainIds["DataPads"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Datapads*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllEnergy"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllProjectile"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllRocket"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["Components"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["EdenComponents"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } //the food in below should already be removed if (root.CsRoot.Root.PlainIds["Ingredient"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientBasic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientExtra"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientExtraMod"].Contains(item.Key)) { root.CsRoot.Move(item, root.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 = root.CsRoot.Move(item, root.E.S, "*DestBox*"); //miList.ForEach(mi => //Console.WriteLine( //$"{mi.Id}\n" + //$"{mi.Count}\n" + //$"\n" + //"")); } } } The script has no errors... it also does not do anything! we have boxes labled appropriatly but nothing happes. If i uncomment my debuc code at the start of the forech loop.. nothing is displayed making me think the way to get the containers may have changed? I am at the limit of what i can figure out with out some help. if anyone know why its not doing anything please let me know. Edit 4: I tried : Code: var container = root.CsRoot.Devices (root.E.S, "A1SortingBox").Where(C => C.Device is ContainerData).FirstOrDefault (); var nativeContainer = ((ContainerData)container.Device).GetContainer() as IContainer; var sItems = nativeContainer.GetContent(); //root.CsRoot.Items(root.E.S, "A1SortingBox"); using the cargo teleport script as reference for how to ...well..reference.. a cargo containers contents. However i then hit another bug: Code: Microsoft.CodeAnalysis.Scripting.CompilationErrorException: (80,68): error CS1061: 'ItemStack' does not contain a definition for 'Key' and no accessible extension method 'Key' accepting a first argument of type 'ItemStack' could be found (are you missing a using directive or an assembly reference?) So GetContant() does get the item stack... but the itemstack does not have the key reference that i use to check what the item is.... ARGHHHHHHHHHHHHH.... With out a functioning IDE i cant look up what attributes these have, and since the cargo transporter just moves weverything it has ne reference for seeing IDs. I dont like to admit defeat and wait for help, but in this case i am going to have to. So how do i fix my script? how do i once again get a list of items from a named chest and then move them based on the item id's to other chests?
Since my last post looks like a wall of text and mistyping due to how tired i was. Here is the question: https://github.com/GitHub-TC/EmpyrionScripting/issues/42 I used to use: var sItems = root.CsRoot.Items(root.E.S, "A1SortingBox"); to get a lit of items in chest named A1Sorting. Then i would iterate through the list using: Code: foreach (var item in sItems) { } and inside that loop i would check each "item"'s ID number against the set lists... Code: if (root.CsRoot.Root.PlainIds["Ore"].Contains(item.Key)) Then if they matched i would move the item stack to a new chest: Code: var ore2 = root.CsRoot.Move(item, root.E.S, "*Ore Box*"); for some reason despite no errors I can not get this to work now. So how do i get a item list of whats inside a named chest that i can iterate through and compare to the ID numbers in the set lists? Please, I am fully stuck on this issue.
I have been struggling with this for 2 days now, turns out I made one typo! the lcd screen that i use to turn the script on and off... the one i check.... I had called DavesNewSort instead of DaveNewSort. I am just going to sit in a corner and not talk to anyone for a bit.
I love that you have done so much on this, and however much of a noob you claim to be, it's way beyond my skill. I understand having little time to do this sort of thing too, so thanks for picking it up ;( Is that the code that works in your post? I can't work it out. I have an LCD called 'ScriptaveNewSort' with the entry text 'DaveNewSort' and an LCD called 'infoOut' Containers called 'A1SortingBox' 'Ore' and so on. 'DaveNewSort.cs' with the code in saved in "[EGS]\Saves\Games\[save name]\Mods\EmpyrionScripting\Scripts", with `Configuration.json` in `...[EGS]\Saves\Games\[save name]\Mods\EmpyrionScripting` to `"CsScriptsAllowedFor": "SaveGame" I get the I've spent 3 hours on this today and need to go parent.
Just saw this but on my way to sleep. The save game script runs on all grids and looks for an LCD called DaveSortLcd (can't look to confirm the name right now but will tomorrow when up) so you don't need to call it. Then place items in the sorting chest and they will be moved to the correct chest as the system does it's thing. With re2 something's aren't moved to correct sorting chests as the system doesn't know them... They go into destBox. The box labeled crafting is the input chest for crafter's. Right I need to sleep but will share the script exactly as it is now when I wake 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 = root.CsRoot.GetDevices<ILcd>(root.CsRoot.Devices(root.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 container = root.CsRoot.Devices (root.E.S, "A1SortingBox").Where(C => C.Device is ContainerData).FirstOrDefault (); //var nativeContainer = ((ContainerData)container.Device).GetContainer() as IContainer; //var sItems = nativeContainer.GetContent(); //root.CsRoot.Items(root.E.S, "A1SortingBox"); var sItems = root.CsRoot.Items(root.E.S, "Sorter"); string temp = ""; /* foreach (ILcd lcd in infoOutLcds) { temp = lcd.GetText(); lcd.SetText("this is a test"); }*/ 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 (root.CsRoot.Root.PlainIds["Ore"].Contains(item.Key)) { if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre") { var ore = root.CsRoot.Move(item, root.E.S, "*Crafting*"); } else { var ore2 = root.CsRoot.Move(item, root.E.S, "*Ore Box*"); } continue; } if (root.CsRoot.Root.PlainIds["OreFurnace"].Contains(item.Key)) { if (item.Name == "PromethiumOre" || item.Name == "PentaxidOre") { var orefurnace = root.CsRoot.Move(item, root.E.S, "*Crafting*"); } else { var ore2 = root.CsRoot.Move(item, root.E.S, "*Ore Box*"); } continue; } if (root.CsRoot.Root.PlainIds["Ingot"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["BlockL"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Blocks Large*"); continue; } if (root.CsRoot.Root.PlainIds["BlockS"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Blocks Small*"); continue; } if (root.CsRoot.Root.PlainIds["Medic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Medical*"); continue; } if (root.CsRoot.Root.PlainIds["Food"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Food*"); continue; } if (root.CsRoot.Root.PlainIds["Sprout"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Plant*"); continue; } if (root.CsRoot.Root.PlainIds["Tools"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Tools*"); continue; } if (root.CsRoot.Root.PlainIds["ArmorMod"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Boosts*"); continue; } if (root.CsRoot.Root.PlainIds["DeviceL"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Devices Large*"); continue; } if (root.CsRoot.Root.PlainIds["DeviceS"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Devices Small*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayer"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Weapons Box*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponHV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*HV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponSV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*SV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponBA"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Base Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponCV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*CV Weapons*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoPlayer"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Hand*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoHV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Small*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoSV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Small*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoCV"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Large*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoBA"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Large*"); continue; } if (root.CsRoot.Root.PlainIds["Armor"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Armour*"); continue; } if (root.CsRoot.Root.PlainIds["Deconstruct"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Deconstruct*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayerUpgrades"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Upgrades*"); continue; } if (root.CsRoot.Root.PlainIds["WeaponPlayerEpic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Weapons Advanced*"); continue; } if (root.CsRoot.Root.PlainIds["Deco"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Decoration*"); continue; } if (root.CsRoot.Root.PlainIds["DataPads"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Datapads*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllEnergy"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllProjectile"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["AmmoAllRocket"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Ammo Misc*"); continue; } if (root.CsRoot.Root.PlainIds["Components"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["EdenComponents"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } //the food in below should already be removed if (root.CsRoot.Root.PlainIds["Ingredient"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientBasic"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientExtra"].Contains(item.Key)) { root.CsRoot.Move(item, root.E.S, "*Crafting*"); continue; } if (root.CsRoot.Root.PlainIds["IngredientExtraMod"].Contains(item.Key)) { root.CsRoot.Move(item, root.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 = root.CsRoot.Move(item, root.E.S, "*DestBox*"); //miList.ForEach(mi => //Console.WriteLine( //$"{mi.Id}\n" + //$"{mi.Count}\n" + //$"\n" + //"")); } } } A lot of things in RE2 end up in the DestBox that needs looking at with the commited out sections. Place it here /Saves/Games/DediGame/Mods/EmpyrionScripting/Scripts the name matters not so long as its a .cs in any base or ship you want the script to run in, simply name an lcd DaveNewSort and it will run. the chest names are with out the * those were added as i believe you can have DestBox1 and 2 and 3 etc The monitor you rename will out put the items in a list it moves.... periodically wipe the text from it, this was mainly done for debugging but I also didnt like a blank lcd.... if you load the script file in notepad++ you will see how it works better, its amazing the difference colour coding can make. Hope all that helps
trying to use simple script for cargo display, but for some reason it work only partially - some items displayed normally, while other replaced with numbers? not sure what i'm doing wrong here Spoiler: general script Code: {{#devicesoftype E.S 'HarvestCntr'}} {{#each .}} Found: {{CustomName}} {{#if CustomName}} {{#items @root.E.S CustomName}} <indent=7%>{{Name}}</indent><indent=72%>{{format Count '{0,0:N0}'}}</indent> {{/items}} {{#devices @root.E.S (concat 'Info:' CustomName)}} {{#each .}} {{#settextblock .}} <align=center>╔{{~bar 1 0 1 36 '═'}}╗ {{../../../CustomName}} {{bar 1 0 1 20 '-'}}</align> {{#items @root.E.S ../../../CustomName}} <indent=7%>{{Name}}</indent><indent=72%>{{format Count '{0,0:N0}'}}</indent> {{/items}} <align=center>╚{{bar 1 0 1 36 '═'}}╝</align> {{/settextblock}} {{/each}} {{/devices}} {{/if}} {{/each}} {{/devicesoftype}}
better use {{i18n id}} instead of {{Name}} and in SinglePlayer you may have to enter the path to the scenario in the scripting configuration file
I am currently trying to combine the new orderbylist function with Viper's Item Overview script. From what I understand I think the best place to integrate it would be before the information is put into an array that is ultimately recalled at the very end of the script. I essentially need to replace sortedeach function around line 8 of the code. Is it possible to do this given everything else that is going on in the script? I am new to all of this and have been learning by taking apart and putting back together scripts that I find on here or from Astic's demo ships. It has been fun, but this feels like a deep end project, but would be amazing helpful on my Helios carrier..... Even just tips/hints would be appreciated.
Hello everyone! I just started playing Empyrion about a month ago when it was free on the Epic Games Store, and I'm loving it so far. I installed the scripting mod and the example savegame scripts, and have been playing around with them a bit. I am familiar with coding, but I'm having trouble figuring out the Format tag and string manipulation (split, substring, etc.), and how to call variables after a {{set}}. The documentation on Github only shows the syntax of the tag itself. Also, since I'm on the Epic version, I cannot use any of the script example blueprints from Steam Workshop. I'm wondering if it would be possible to put them on Nexus, so that I can use them (or just attach the .ebp files here, if possible)? Any help would be greatly appreciated!
You can also subscribe to the blueprints from the Steamworkshop and then pack the *.EBP files from the Steam directory [Steam]\steamapps\workshop\content\383120\... into your blueprint folder of the game. You will then have access to them the next time you start the game
I only own the game on Epic Games Store, not Steam, so that folder doesn't exist on my PC. Nothing downloads when I subscribe to anything on the Workshop.
You're right, to access the workshop in Steam you obviously have to own the game. You seem to have uncovered another big construction site here that Eleon has torn open when making it available on EPIC :-( PS: The upload function in the game should not exists on EPIC either PSS: i have added the Scripting-Demo-CV and the VegaAI copy the EPB files in your empyrion blueprint directory and start the game