Jump to content

solved Activating custom PartModule freezes game after restarting flight


Recommended Posts

Hello,

I'm writing a new part module which is an advanced SRB. For new ships (straight from the VAB or using the select ship box on the Launchpad) the plugin works as expected. However, after restarting a flight or loading a flight already on the Launchpad, activating the part causes the game to freeze.

1. I suspect the problem is with the plugin working after loading from the persistence file.

2. Output log shows that the program is running through the end of the OnActivate() sub, but stops somewhere before getting into OnFixedUpdate() (it may actually enter the code block, but a print() message as the first line of the OnFixedUpdate() sub does not show up in the log

3. As long as I don't activate the custom part module, the game runs fine.

I don't have internet at my development computer until tomorrow, but I may be able to post the code up sometime tonight.

Thanks for your help.

Edited by kujuman
Solved my stupid errors
Link to comment
Share on other sites

hm, I thought I had updated the post...

Anyway I have solved the issue.

It was due to a do loop getting stuck because part.attachnode.attachedPartId.ToString() returns the attached part and id number just fine when loading a new vessel. (It will return something like "CommandPod1-2_49295810560054")

However, this returns "" when the game creates a vessel from a save file. Which is...weird. Anyway, I instead used part.attachnode.attachedPart != null (which returns the attached part as a Part class) which does work after loading from a save.

So all in all, always remember to put some failsafe way out of loops and part.attachnode.attachPartId.ToString() should not be used on flight vessels, but would probably work ok for editor type stuff

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