• Content Count

  • Joined

  • Last visited

Community Reputation

64 Excellent

About asdfCYBER

  • Rank
    Spacecraft Reverse Engineer

Recent Profile Visitors

1,328 profile views
  1. Current progress: I have replaced the experiment UI. The buttons currently don't do anything (except that they all close the window), but the save button will save the data to a storage module based on module priority, and the transmit button will probably require DMagic's Science Relay mod or large sections of it (and have the data value decrease over distance based on antenna properties) in the future. Here's a picture of the old UI and my UI side by side: I will probably change the title and description to the style on the left, but I'm very happy with how it looks (especially since this is the first UI I made for KSP and had to endure a good deal of unity and textmeshpro weirdness - thanks a lot @DMagic for your UI tutorial!). One thing I'm not totally sure of is the transmit icon - I made two versions and am currently using the most stockalike, but the other might blend in better with my other new icons: Please tell me which one y'all like better Edit: there's also a github repo now, and a roadmap.
  2. I'm trying to follow DMagic's UI tutorial, and I am currently trying to get my head around interfaces - and buttons. I can call any public function with OnClick(), but I'm not sure how to send that event to the KSP assembly. What I've thought of are setting some variable to a certain value and checking every once in a while through the interface if that variable has changed, and calling a GameEvent which gets picked up by the other assembly (I'm not sure if that's possible). Would either of these methods work, or is there a better way to do this?
  3. I'd like my name changed from ExtremeTrader to asdfCYBER please, I'm neither extreme nor a trader and I use asdfCYBER everywhere now. Thanks!
  4. I'm having the exact same problem. Before I try to recreate what you did, can you confirm your assets work in KSP? (edit: I'm not making KSPedia entries but GUIs, though if one works I assume the rest does as well)
  5. Yes, I'm planning to use the science lab as a data-to-science converter. There is no need for science-to-data, instead the whole standard science system will be ignored (experiments now collect data). I'm not sure if I want the research to take time, I don't want to add too much of a grind. I might make it optional at a later stage in development, right now I'm trying to get the basis up and running (replacing the techtree will probably be the most difficult, and I need to reinvent multiple GUIs which will be very timeconsuming)
  6. After getting stuck on one very specific bit of the mod, I have now actually started doing things. That makes this mod a WIP now! So far, I implemented a partmodule that intercepts science reports and one that stores the results, next step is to make a GUI for those reports
  7. Hi all, I would like to figure out how much science something returns from a certain location if the experiment was recovered or transmitted using these objects: ScienceData data and ScienceExperiment experiment. I know that data.subjectID gives me a string experimentID@location, and experiment.baseValue and experiment.scienceCap are the base values, but I do not know how to calculate the science at a location with these. Does someone here know? (edit: of course I could test all experiments at all locations and hardcode a solution, but I'm looking for a simple algorithm or api call) edit2: probably solved, just discovered that the ResearchAndDevelopment class has a bunch of science value related methods like ResearchAndDevelopment.GetScienceValue(dataAmount, scienceSubject) edit3: So here's my next question I haven't been able to figure out: I have a confignode CONTAINED_DATA in which an unknown amount of entries (of the form subjectID:dataAmount) are stored, which looks like this: CONTAINED_DATA { atmosphereAnalysis@KerbinFlyingLowShores = 200 atmosphereAnalysis@KerbinSrfLandedLaunchPad = 200 asdf = 42 } I have been trying to get my code to add these entries to a dictionary called containedData by looping over the nodes in CONTAINED_DATA: foreach (ConfigNode dataNodeKey in dataNode.GetNodes()) { string key = dataNodeKey.ToString(); float value = float.Parse(dataNode.GetValue(key)); containedData.Add(key, value); Debug.Log(key + " was added to the dictionary"); } However, nothing gets added to this dictionary and the log mentions nothing about added keys. I have also tried looping over dataNode.nodes and returning a bunch of objects, which all seem to be empty. Here is the log with comments: [LOG 22:28:57.178] OnLoad called //the onload method is called in my partmodule [LOG 22:28:57.178] MODULE //the node is dumped to the log { name = ModuleDataContainer isEnabled = True stagingEnabled = True EVENTS { } ACTIONS { } CONTAINED_DATA //the node (called dataNode in the code) where various entries are stored, which are not known in advance { atmosphereAnalysis@KerbinFlyingLowShores = 200 atmosphereAnalysis@KerbinSrfLandedLaunchPad = 200 asdf = 42 } UPGRADESAPPLIED { } } [LOG 22:28:57.178] GetNodes: ConfigNode[] //dataNode.GetNodes().ToString() returns what seems to be an empty list of confignodes [LOG 22:28:57.178] nodes.tostring: ConfigNode+ConfigNodeList //dataNode.nodes.ToString() returns something I can't decipher [LOG 22:28:57.178] Values: System.String[] //dataNode.GetValues().ToString() returns what seems to be an empty list of strings [LOG 22:28:57.178] This really should work: 200 //directy accessing an entry does work but is not usable when entries are unknown [LOG 22:28:57.178] containedData is empty //nothing got added to the dictionary [LOG 22:28:57.178] OnLoad finished What can I loop over to add the entries to my dictionary and how? edit4: I created a workaround so that key and value are stored separately (which is a lot less practical), but I still hope there is a solution for key = value entries with unknown keys
  8. You can do this using ModuleManager (you already have it installed if you have RO+RSS). If you want to edit engines you can make a new .cfg in your gamedata folder and use this (I haven't tested it): @MODULE[ModuleEngines] { @PROPELLANT[MonoPropellant] { @name = otherMonopropGas } } for RCS, something like this should work: @MODULE[ModuleRCSFX] { @resourceName = otherMonopropGas } Of course, you need to make sure that your otherMonopropGas is actually defined in a resourcedefinition cfg somewhere, but if you change it to one of the real fuels resources you don't need to think about that. I suggest that you practice writing MM patches, they can be very useful. Some syntax explanation can be found here:
  9. That does make sense, but it's not set as out or ref or even optional ( When I try to use CommNetwork as a type visual studio mostly flips out and breaks control loops for some reason (edit: your code doesn't give errors however, not sure what happened). edit 2: threw your code in a method and found this in the log: [ERR 16:35:03.203] Module ResourceTransceiver threw during OnUpdate: System.NullReferenceException: Object reference not set to an instance of an object at CommNet.CommNetwork.FindPath (CommNet.CommNode start, CommNet.CommPath path, CommNet.CommNode end) [0x00000] in <filename unknown>:0 at ResourceBeamer.ResourceHandler.somemethod (.Vessel vessel1, .Vessel vessel2) [0x00000] in <filename unknown>:0 at ResourceBeamer.ResourceTransceiver.OnUpdate () [0x00000] in <filename unknown>:0 at Part.ModulesOnUpdate () [0x00000] in <filename unknown>:0 I'm pretty sure that's a nullref about the path being null, I don't know how to get a path though
  10. Is there a way to check if there is a CommNet path between two vessels that are not necessarily connected to Home, and get the total distance and signal strength? I can't find anything of use here in the CommNet classes and I wouldn't know how to make this myself. Edit: seems like asking this improved my chances of finding the right thing, because I think override void CommNet.CommNetwork.CreateShortestPathTree(CommNode start, CommNode end) or override bool FindPath(CommNode start, CommPath path, CommNode end) might be what I was looking for, though I don't understand how to use these (getting a path from a pathtree that is not returned? find the best path when I don't have a path? findpath returns bool instead of path?)
  11. Nothing. I feel like [KSPField()] is the way to go, but everything I try ends up in the part not being loaded . When using KSPField, OnLoad and OnSave should not be necessary so I will try removing those. I tried adding [KSPModule("Resource Transceiver")] too, but that did not do anything about the error. Edit: I commented out OnLoad and OnSave, now everything outputs LiquidFuel as it should, and it shows up in the .craft file too. Thanks for the help!
  12. This is all of my code currently: using UnityEngine; namespace ResourceTeleporter { public class ResourceTransceiver : PartModule { public string ResourceName { get; set; } /// <summary>Load resource from config</summary> public override void OnLoad(ConfigNode node) { ResourceName = node.GetValue("resource"); Debug.Log("[RT] OnLoad " + ResourceName); } /// <summary>Get resourceID from name</summary> public int GetResourceID(string ResourceName) { PartResourceDefinition Resource = PartResourceLibrary.Instance.GetDefinition(ResourceName); return; } /// <summary>Get resources in the vessel this part is part of</summary> public double GetVesselResourceAmount(int ResourceID) { this.vessel.GetConnectedResourceTotals(ResourceID, out double amount, out double maxAmount); Debug.LogWarning("[RT] Current vessel resources: " + amount + " (max: " + maxAmount + ")"); return amount; } public override void OnStart(StartState state) { Debug.Log("[RT] OnStart " + ResourceName); } public override void OnUpdate() { Debug.Log("[RT] OnUpdate " + ResourceName); } } } This returns (plus some relevant bits): [LOG 10:54:19.149] PartLoader: Compiling Part 'Squad/Parts/Utility/rcsBlockRV-105_v2/rcsBlockRV-105/RCSBlock_v2' //ksp startup [LOG 10:54:19.158] [RT] OnLoad LiquidFuel //the only time it works correctly [LOG 10:55:09.555] [RT] OnStart //editor [LOG 10:55:11.314] RCSBlock.v2 added to ship - part count: 4 //the part I attached the module to [LOG 10:55:22.462] Loading ship from file: C:/Program Files (x86)/Steam/steamapps/common/Kerbal Space Program/KSP_x64_Data/../saves/default/Ships/VAB/Auto-Saved Ship.craft [LOG 10:55:22.462] [UIMasterController]: HideUI [LOG 10:55:22.491] [RT] OnLoad //switch from editor to flight [LOG 10:55:25.946] [RT] OnStart //flight, gets spammed for every update so I just pasted one here [LOG 10:55:26.259] [RT] OnUpdate //flight ResourceTransceiver.ResourceName gets reset on scene switches apparently (it doesn't even get overridden like on the editor->flight switch, there is no OnLoad between startup and editor). It probably should have a KSPField property, I'm going to test that now. edit: added [KSPField(isPersistant = true)] in the line before ResourceName, part did not compile (same thing with just [KSPField()]): [LOG 11:17:09.478] PartLoader: Compiling Part 'Squad/Parts/Utility/rcsBlockRV-105_v2/rcsBlockRV-105/RCSBlock_v2' [EXC 11:17:09.488] MissingMethodException: No constructor found for BaseField::.ctor(KSPField, System.Reflection.MonoProperty, ResourceTeleporter.ResourceTransceiver) System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) System.Activator.CreateInstance (System.Type type, System.Object[] args) BaseFieldList`2[R,K].CreateList (System.Object instance) BaseFieldList.CreateList (System.Object instance) BaseFieldList`2[R,K]..ctor (System.Object host, Boolean ignoreUIControl) BaseFieldList`2[R,K]..ctor (System.Object host) BaseFieldList..ctor (UnityEngine.Object host) PartModule.ModularSetup () PartModule.Awake () UnityEngine.GameObject:AddComponent(Type) Part:AddModule(String, Boolean) Part:AddModule(ConfigNode, Boolean) PartLoader:ParsePart(UrlConfig, ConfigNode) <CompileParts>c__Iterator1:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) [ERR 11:17:09.488] PartLoader: Encountered exception during compilation. System.NullReferenceException: Object reference not set to an instance of an object at PartModule.Load (.ConfigNode node) [0x00000] in <filename unknown>:0 at Part.AddModule (.ConfigNode node, Boolean forceAwake) [0x00000] in <filename unknown>:0 at PartLoader.ParsePart (.UrlConfig urlConfig, .ConfigNode node) [0x00000] in <filename unknown>:0 at PartLoader+<CompileParts>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0 [ERR 11:17:09.489] PartCompiler: Cannot compile part I could store ResourceName in a different class perhaps
  13. It still doesn't, Debug.Log("[RT] onupdate " + ResourceName) only yields a spam of the string bit just like OnStart. I'll try reverse engineering another mod. Edit: InterstellarFuelSwitch seems to call another method on load which puts inputs in variables that can be read in other scopes: Dictionaries and lists are too complicated for what I want, but I'll try the anothermethod-method tomorrow (2300 pm here)