KspNoobUsernameTaken Posted June 7 Share Posted June 7 How do you access a config node? I've been using this code but can't seem to figure it out: public class BPManagedResource { //public string ManagedResource = ConfigNode.GetNode("BPManagedResource"); public void OnLoad(ConfigNode BPManagedResourceNode) { string BPManagedResourceValueHelper = BPManagedResourceNode.GetValue("BPManagedResource"); } public string BPManagedResourceValue = BPManagedResourceValueHelper } But it keeps giving this error: Error CS0103: The name 'BPManagedResourceValueHelper' does not exist in the current context Quote Link to comment Share on other sites More sharing options...
0111narwhalz Posted June 10 Share Posted June 10 On 6/7/2024 at 12:34 AM, KspNoobUsernameTaken said: Error CS0103: The name 'BPManagedResourceValueHelper' does not exist in the current context This indicates that the variable name has exited the scope. If you look at the curly brackets, the variable BPManagedResourceValueHelper was defined inside the function OnLoad. If you try to use it outside of that function, there's no way for the compiler to know what variable you're talking about (since there might be other functions with variables with the same name in them, or indeed none at all). Instead, you need to define BPManagedResourceValue in the class scope, as you have, and then set it in the function scope (since that's where […]Helper is defined). Order shouldn't matter here, but it's considered good practice to put your class variables ("fields") above your class functions ("methods"), so you can immediately see all the fields of a class. Quote Link to comment Share on other sites More sharing options...
KspNoobUsernameTaken Posted June 10 Share Posted June 10 7 minutes ago, 0111narwhalz said: This indicates that the variable name has exited the scope. If you look at the curly brackets, the variable BPManagedResourceValueHelper was defined inside the function OnLoad. If you try to use it outside of that function, there's no way for the compiler to know what variable you're talking about (since there might be other functions with variables with the same name in them, or indeed none at all). Instead, you need to define BPManagedResourceValue in the class scope, as you have, and then set it in the function scope (since that's where […]Helper is defined). Order shouldn't matter here, but it's considered good practice to put your class variables ("fields") above your class functions ("methods"), so you can immediately see all the fields of a class. Thank you, but I think I solved this. It is still quite helpful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.