Jump to content

GameEvent: onDock and several other events


Recommended Posts

Hello,

I am building a mission plugin and I need to check, if the vessel has docked to another ship. Unfortunately GameEvents provides onUndock but no onDock event. Is there another way to check this event?

Also I would like to know how many tons of a specific resource are available on the vessel (only the name of the resource is known, e.g. "Oxidizer"), how do I do that? I don't see any suitable methods in Vessel or PartModule.

And finally I would like to know whether or not more file access methods are planned. I would like to access the directories,where my mission files are, but that is not possible (accessing System.IO is forbidden). I use FileBrowser so far, but that has other issues.

Thank you very much!

Link to comment
Share on other sites

There are a few new file access methods in GameDatabase.

Err.... I don't see them?

And thanks the devs for that, wouldn't be safe to download any plugins otherwise.

I didn't blame the devs for this step. But I wish there were other methods (especially accessing the directory itself) to access the PluginData-folder from my plugin.

Link to comment
Share on other sites

But I wish there were other methods (especially accessing the directory itself) to access the PluginData-folder from my plugin.

OnSave and OnLoad can do that to an extent. If you're trying to access an image then just use that image's name and KSP will automatically pull it from PluginData. Sounds are more complicated (due to the new GameData thing) but it's a similar method. I know Snjo figured it out (mostly) so look for that thread in this subforum.

Link to comment
Share on other sites

OnSave and OnLoad can do that to an extent. If you're trying to access an image then just use that image's name and KSP will automatically pull it from PluginData. Sounds are more complicated (due to the new GameData thing) but it's a similar method. I know Snjo figured it out (mostly) so look for that thread in this subforum.

Maybe I didn't describe it properly: I want to access the directory. I want to see which files are there, and of course, I want to open them. For now I use KSP.IO.TextReader and FileBrowser and it works, but it has some side effects.

I figured out how to access the resources, maybe there are simpler methods:

Iterate over all parts on your vessel, each part has the Resources property and you can access the resource by using ["LiquidFuel"] as accessor.

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...