Jump to content

KSP Modding noob with somewhat basic questions


wpatter6

Recommended Posts

Hi, I have been going through the tutorials I could find, and couldn't find info about a couple of items. My next step was to dig through the source of existing mods but I was thinking maybe someone on here could answer my questions more easily, so here goes.

My main question is how are people typically storing data on the client? I've tried setting up using the SQLite as well as Newtonsoft.Json dlls but every time I fire up the game it throws an error. For SQLite it says "[Exception]: FileNotFoundException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies." For Newtonsoft.Json it says "[Error]: AssemblyLoader: Exception loading 'KerbalFeels': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded."

I am using VS 2012 and added the assemblies in the normal way. I also made sure windows hadn't flagged them as "blocked" in their properties. I'm assuming that these packages are not allowed in the game and that's why the errors are being thrown, if so, is there some definition or logic behind what assemblies are and are not allowed?

I'm really just wondering what people are typically doing to store and retrieve data on the client in their add-ons. I've tried googling and looking at the tutorials on the wiki but nothing seems to touch on this piece. If I'm just being dumb and there's some other site or threads I should be looking at for info like this please link me and I'll be on my way, thanks.

Link to comment
Share on other sites

Interesting, are you looking at storing massive amounts of data?

The in-game system we have for data storage is the ConfigNode (in the class of the same name) which can be read/write to disk as a text file.

The other thing that error message implies is that the Net version is off. You have to build against Net version 3.5 to make a .dll file KSP can load.

Hope that helps,

D.

Link to comment
Share on other sites

Well, probably not *massive* but I suppose it would want to be able to scale up to some degree... Hmm I thought I had gotten the 3.5 versions but, oh well, this ConfigNode looks to be a lot like Json so I think it'll probably work for what I'm doing at the moment. I'm really just taking broad strokes at the moment to see how feasible my idea is, thanks a lot for your help

Link to comment
Share on other sites

There are several common methods you can use depending on what you want to achieve.

General Plugin Settings

KSP.IO.PluginConfiguration is useful for easy storage of simple settings. It has the capacity for automatically handling defaults when no settings exist, but is awkward to use for save specific data or when you need multiple of the same dataset


KSP.IO.PluginConfiguration config;
config = KSP.IO.PluginConfiguration.CreateForType<AClass>();
config.load();

value = config.GetValue("ValueID", defaultValue); // retrieve the data stored with "ValueID" key, use defaultValue if not found
config["ValueID"] = valueUpdate; // assign valueUpdate to the "ValueID" key

config.save();

Example

Persistent Data (Save Files)

Part Modules mostly use this, but partless plugins can also save/load data to/from the save file. These are saved as confignodes, but they are automatically associated with a specific save unlike a general confignode. A class inheriting from ScenarioModule can override the save/load methods like this

ConfigNodes

Useful for storing multiple instances of a template and/or more complex data without having to worry about how serialisation is dealt with (which can be a pain with the pluginData method). No built in way to load default values though.

Example

Edited by Crzyrndm
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...