Sarbian changed the topic of #kspmodding to: Welcome to #kspmodding - the channel for discussing, and learning about, modding Kerbal Space Program. Code of Conduct: https://git.io/vSQh6 | Always provide logs. | *** PSA: https://kerbalspaceprogram.com/api/index.htm | Someone is writting a Phd dissertation on KSP modding please fill out this survey https://goo.gl/forms/1vrkPYH4az8l32sb2 - I have met him and it s legit
Ezriilc has quit [Ping timeout: 200 seconds]
BasharMilesTeg has joined #kspmodding
BasharMilesTeg_ has quit [Ping timeout: 207 seconds]
blowfish has joined #kspmodding
BasharMilesTeg_ has joined #kspmodding
BasharMilesTeg has quit [Ping timeout: 207 seconds]
blowfish has quit [Quit: Leaving]
<Sigma88>
question...
<Sigma88>
what do I need to do to store a value in a PartModule
<Sigma88>
between OnLoad and OnSave
<Sigma88>
every time I set the value of something at OnLoad I end up with it going back to **null** at OnSave
<Sigma88>
>_>
<Sigma88>
xShadowx?
<xShadowx>
Sigma88: [KSPField]
<Sigma88>
it doesn't work with ConfigNode
<xShadowx>
public string mystriing = "hello";
<xShadowx>
o.O
<Sigma88>
I have 30 fields, and I already have a method to parse them from the node
<Sigma88>
I'd rather not have to use 30 kspfields
<xShadowx>
errr
<xShadowx>
any reason you're parsing them yourself?
<Sigma88>
they are settings for a custom object that I already parse somewhere else
<Sigma88>
I decided to add it also as a partmodule
<xShadowx>
when the partmodule loads (before Onload is called) it parses the confignode its loading from, filling the kspfields
<xShadowx>
and reverse for OnSave
<xShadowx>
no need to parse/load yourself usually, just kspfield on the fields and done
<xShadowx>
can even call load yourself and pass it the confignode if your trying to create stuff mid scene
<xShadowx>
or im missin somethin since i literally woke up just now ;p
<xShadowx>
oh
<Sigma88>
I'm not sure how that is going to help me
<xShadowx>
[kspfield(isPersistent=true/false)] too :|
<xShadowx>
i think default is true'
<xShadowx>
is false, doesnt save it at all
<xShadowx>
runs off the default of whatever is in the part file
<xShadowx>
like maxthrust on an engine, no need to persist
* xShadowx
stumbles away like a zombie to make morning tea
<xShadowx>
brain dead :|
<xShadowx>
ok tea, now what broke?
<xShadowx>
Sigma88: oh tryin to store a whole object there?o.o
<Sigma88>
yeah
<Sigma88>
I need to store a whole ConfigNode
<Sigma88>
I don't understand why it resets in the first place
<xShadowx>
at onload, you store the ref of the confignode there, at onsave, save it?
<xShadowx>
it should work >.> dont think anythin destroys em
<Sigma88>
I've already tried it
<Sigma88>
it doesn't work
<xShadowx>
that seems weird
<xShadowx>
i never tried to store/save node, i went the route of creating a class, [Persistent] on all the fields, then confignode.CreateObjectFromConfig heh
<xShadowx>
or just kspfields themselves
<xShadowx>
storing confignode always seemed wrong for some reason
<xShadowx>
but no idea why ref shouldnt stay there :|
<Sigma88>
ah wait
<Sigma88>
OnLoad is triggered during the loadingscreen?
<Sigma88>
yes it's triggered there
<Sigma88>
which means by the time I reach the editor everything resets
<xShadowx>
its ran at the start for prefabs (i think?) then again when parts are instantiated (loading vessel for flight)
<xShadowx>
needa get ready for work back in a few, sorry :|
<Sigma88>
I think I solved it
<Sigma88>
I generate a DataBase during the first loading and then I use that one
<xShadowx>
i seem to remember somethin about objects transfered between prefab and part once insantiated need to be serializable else dont copy over, no clue if confignode was, if it was null in editor then prolly not ;p