Jump to content

[Workaround found] Making a <LIST> Persistent


Recommended Posts

Does anyone have an example of how to make a <LIST> persistent?  I've tried this but it's not working.  I'm not real sure how the collectionIndex (or any of the other settings: i.e. name =, pass = ) works and haven't found a good example.  This is a PartModule if that makes any difference.

[Persistent(collectionIndex = "MyList")]
public List<MyList> MyStuffList = new List<MyList>();
  
  
		public override void OnStart(StartState state)
		{
		if (MyStuffList.Count == 0)  //assuming this is a newly created vessel without a list
  			{
  				... populate the list.
			}
		}

Thanks.

Edited by Fengist
Link to comment
Share on other sites

Yeah, I think if you're going to make the list persistent across _loads_, it has to be saved in a cfg file (or some other file type). Otherwise if it's just across scenes and reloads, you might be able to do something with a holder class that is active in all scenes, which should make it persistent in that sense. 

Link to comment
Share on other sites

@Fengist ConfigNode is your best option .... I tried doing a list in the part module for the HoloCache system I'm working on in OrX (GeoCache/enemy vessel spawning) and I found that in the end it's less hair pulling than trying to get the part module to carry the info

Take a look at the BDAc GPS system, it will have what you need (BDATargetManager etc....)

Edited by DoctorDavinci
Link to comment
Share on other sites

27 minutes ago, DoctorDavinci said:

@Fengist ConfigNode is your best option .... I tried doing a list in the part module for the HoloCache system I'm working on in OrX (GeoCache/enemy vessel spawning) and I found that in the end it's less hair pulling than trying to get the part module to carry the info

Take a look at the BDAc GPS system, it will have what you need (BDATargetManager etc....)

Yep, I got it saving and loading values using ConfigNode with the OnSave/OnLoad events.  But, that ended up bringing yet another problem to light, which I'm starting yet another thread for... thanks.

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