Thanks! And here the next question: Code: CsRoot.Items(E.S,"*").ForEach(item => { CsRoot.Fill(item, E.S,StructureTankType.Fuel,50); }); Works fine, but: Code: CsRoot.Items(E.S,"*").ForEach(item => { CsRoot.Fill(item, E.S,StructureTankType.Fuel,50); CsRoot.Fill(item, E.S,StructureTankType.Oxygen,30); CsRoot.Fill(item, E.S,StructureTankType.Pentaxid,40); }); brings the error message: Only allowed on SaveGameScripts. Code: CsRoot.Items(E.S,"*").ForEach(item => { CsRoot.Fill(item, E.S,StructureTankType.Oxygen,30); }); brings this error mesage, too. Is the constant "Oxygen" and "Pentaxid" the wrong spelling? Or is it a bug?
It's not a bug, just (incorrectly) not released for player scripts. If you are in [EGS]\Saves\Games\[SaveGame]\Mods\EmpyrionScripting\ sCompilerConfiguration.json the "WithinLearnMode": true, if you turn on all unknown things are automatically written into the SaveGame section and you can move the entries you need into the Player section eg here you need a "EmpyrionScripting.Interface.StructureTankType.*", in the player section. The wildcard * allows everything in this type I have updates this in the current 5.6.1 ;-)
I got memory usage warnings from my server after start using C# scripts. Is a garbage collector in place? Is it "safe" to use the "new" operator in the scripts?
I set "WithinLearnMode: true" but unfortunately nothing is added to the "SaveGame" section. I get a "allowed in SaveGameScript" message at trying to use "item.GetType()" but no Entry appears in the "SaveGame" Section. Additionally I'm not even sure if "GetType" is what I need. I want to read the "group" of the item. "ammo" for example.
For the group issue:: "Group" seems not to be a valuable "Attr" in "ConfigById". I tried to read the attribute list of several item-ids and found no "Group" attribute or value in one of it. For the memory issue: I removed the script-demo-vessel from my playfield and the memory-usage stays constant even with the "new" operator in several of my scripts. Whatever produces the memory leak it must be in one of the scripts of the demo-vessel. For the rights issue I added to "Player": "System.Environment.*", "System.Math.*", "System.double.*",
Code: { Block Id: 53, Name: SathiumResource Material: resourcehard Group: resource { Child DropOnDestroy Count: "2,4" Prob: 0.2 } } Note: You need Playeraccess for "EcfParser.*" or in HBS
hmmmm, there is a inconsistence in the config attribute structure. Try to read the group of id 2248 for example. There is no group. Maybe I miss some basics but how to link the "high-level" ids of the ingame-visible items to the "low-level" ids in the parent structure of the items? The groups in your example only exists in the low-level item ids. Most ingame-visible Items have no Group: The Testcode: Code: CsRoot.Items(E.S,"*").ForEach(I=>{ Console.WriteLine(I.Name+": "+ CsRoot.ConfigFindAttribute(I.Id,"Group")); }); shows no Groups:
I'm not at all sure if there is such an assignment directly - maybe it is also hard-coded in the game?!? @Sephrajin has created many lists that I have built into the standard and which can be called up via the "Ids" directory.
"Ids" is protected in savegamescripts . Where is it located? Maybe "System.Ids.*", "EcfParser.Ids.*" or "EmpyrionScripting.Ids.*" ? I searched the description of "Ids" without success on the EmpyrionScripting GitHub Page. Do I need glasses? Next Question. I try to use the "IContainer" class interface: Code: var C = CsRoot.GetDevices<IContainer>( CsRoot.Devices(E.S,"*")); Console.WriteLine(C.Count()); C.ForEach(D=>{Console.WriteLine(D.CustomName); }); On GitHub I found that IContainer should have a member called "CustomName" but ingame I got the compiler error "no such member". I have "Eleon.Modding.IContainer.*" placed in the player section. Where is my fault?
I've not tried the C# scripting yet, but if its anything like the handlebars version CustomName doesn't get populated until you actually set a name for a component - the game itself doesn't populate that field when it's still the 'default' name and there isn't a "regular" name field in the same way (you can pull out some things by delving through the config then feeding it through the localisation with "i18n") So for example, you put down a standard cargo box and in the control panel device list it shows as "Cargo Box", when you select it the text area where you rename it is empty by default - that is where CustomName pulls from - so when you rename it to "Weapons Box" then customname becomes populated
"Ids" is a Dictionary at root level ;-) CustomName ich NOT a property of IContainer, only of IBlock and a small doc for the ModApi you will find here [EGS]\Content\Extras\Modding Doc Code: Console.WriteLine(Ids["AmmoPlayer"]); var C = CsRoot.Devices(E.S,"*") .Select(B => new { B, D=E.S.GetCurrent() .GetDevice<IContainer>(B.Position) }) .Where(C => C.D != null); Console.WriteLine(C.Count()); C.ForEach(D=>{ Console.WriteLine(D.B.CustomName); });
But with which Id? I try to get a "identification element" from "D" without success. No "CustomName", no "Name", no "Id". I do not find the correct spelling for any identification member to use in other lookup-methods. This I cannot retrace. The "Name" field in the controlpanel is never empty. Even at a newly placed device (container) the field is filled with a "standard name". So how can CustomName not be populated if I do not clear this field manually? And even if its empty, a user filled field should not lead to a non- existing class member. Wow, I have to learn much more about the concatenated standard methos of C#. The possibilities are interessing. Thanks But your "container example part" and the "Ids example part" both run in "only allowed in savegamescript" message. I get gradual annoyed by this message. Is it possible to "set everything allowed by default"?
At this point, I prefer to be careful, because if you accidentally release too much, you can do a lot of damage on a server. Therefore, entries are sometimes missing, which you can simply add yourself and then please let me know so that I can add them to the standard.
My problem is to identify the correct missing entry. The "WithinLearnMode: true" entry does nothing in my file. Would it be possible to let the ingame message show the missing entry name path?
Found the next: Code: ....if(V.Id!=E.Id&&V.EntityType!=EntityType.Base){... The EntityType constant is not allowed.
I don't have to place the entry. It was already there. I just changed "false" to "true". But my file has a little different name. "CsCompilerConfiguration.json" does not exist in my directory. I only have a file named "DefaultCsCompilerConfiguration.json". Maybe that's the reason? Adding the correct namespace path to this file activates the permission as you mentioned, but the LearnMode doesn't work.