Thomas 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.html | <Red5> Guy was asked for a log file, he gave this link: http://pastebin.com/wfVarZPf | If you haven't read it yet: Logs :P
blowfish has quit [Quit: Leaving]
Ezriilc has quit [Quit: Going offline, see ya! (www.Kerbaltek.com)]
tfool has joined #kspmodding
Technicalfool_ has quit [Ping timeout: 204 seconds]
rsparkyc has quit [Quit: Leaving.]
SirKeplan is now known as SirKeplanzzz
Pap is now known as Pap|Away
NathanKell|Twitch is now known as NathanKell|AFK
NathanKell|AFK is now known as NathanKell
NathanKell is now known as NathanKell|Twitch
blowfish has joined #kspmodding
BasharMilesTeg_ has joined #kspmodding
BasharMilesTeg has quit [Ping timeout: 383 seconds]
BasharMilesTeg_ is now known as BasharMilesTeg
NathanKell|Twitch is now known as NathanKell|AWAY
blowfish has quit [Quit: Leaving]
ferram4 has quit [Ping timeout: 204 seconds]
<Sigma88> I have a question about coding stuff in KSP
<Sigma88> basically
<Sigma88> Kerbin has a PQSCity mod called KSC
<Sigma88> I can get that using:
<Sigma88> FlightGlobals.GetHomeBody()?.GetComponentsInChildren<PQSCity>()?.First(m => m.name == "KSC");
<Sigma88> then I can get the component "SpaceCenter" using this:
<Sigma88> KSC.GetComponentsInChildren<SpaceCenter>().FirstOrDefault();
<Sigma88> in some weird circumstances, using kopernicus, that component is null
<Sigma88> my question is
<Sigma88> how do I add a "SpaceCenter" component to the KSC PQSCity ?
<Sigma88> I already have the component I want to add ( I can get it using SpaceCenter.Instance )
<ninja81> If those are Unity components as I think they are... you can´t add a component to a component I think
<ninja81> You have to add a GameObject somewhere
<Sigma88> so I need to create a GameObject and then .AddComponent()
<Sigma88> but how do I link the KSC and the SpaceCenter?
<ninja81> A GameObject can be the parent of other GameObjects
<ninja81> And into the GOs you add components
<ninja81> The components are what tell Unity what the objects actually are
<Sigma88> ok
<Sigma88> and to add a GameObject Child?
<Sigma88> how would I do that?
<Sigma88> GameObject doesn't have any "parent" or "child" as far as I can tell
<Sigma88> I mean, there's no "AddChild()" or "SetParent()" method
<Sigma88> I can only "GetChild()"
<ninja81> I think you use AddComponent<Type> with GameObject or a type that ultimately inherits from it
<Sigma88> so GameObject.AddComponent<GameObject>(myGO)
<Sigma88> I'll try that
<Sigma88> thanks
<ninja81> Look in the KSP API for any classes in KSP that extend GameObject, too
<Sigma88> thanks
<ninja81> no problem
smoke_fumus has joined #kspmodding
smoke_fumus has quit [Client Quit]
<Sigma88> so, it turns out that the the GameObject already exists
<Sigma88> but it has the wrong parent
<Sigma88> can I just change the parent?
<Sigma88> or do I need to destroy that GameObject and create a new one?
<ninja81> destroy and recreate
<Sigma88> ok
<Sigma88> and if I destroy the GameObect I don't destroy the components in it right?
<ninja81> Probably does, unless maybe you got a reference first
SirKeplanzzz has quit [Ping timeout: 204 seconds]
<Sigma88> ugh
SirKeplan has joined #kspmodding
<Sigma88> I could try adding a new object with the components I need first
<Sigma88> and then delete the old object?
<ninja81> I suppose... if you can actually clone them
<Sigma88> I can't add a GameObject using AddComponent
<Sigma88> >_>
<Sigma88> yes I was starting to look for that kind of stuff
<Sigma88> oh wait
<Sigma88> GameObject.transform.parent
<Sigma88> I think that's it
<ninja81> a transform is the XYZ coordinates of the object.. its parent is the object
<Sigma88> they say to do: this.transform.parent = yourParentObject;
<Sigma88> (which seems to work)
<Sigma88> even tho sadly it doesn't fix my issue >_>
TriggerAu has joined #kspmodding
TriggerAu has quit [Ping timeout: 201 seconds]
TriggerAu has joined #kspmodding
<taniwha> Sigma88: of course you can't use addcomponent to create a gameobject
<taniwha> addcomponent adds a component to a gameobject
<taniwha> Sigma88: plaque = new GameObject ("Survey Plaque");
<taniwha> it's as simple as that :)
<taniwha> or as complicated as GameObject go = new GameObject ("Survey Plaque Canvas", typeof (RectTransform), typeof (Canvas), typeof (CanvasScaler));
<Sigma88> and to parent it I just need to do go.transform.parent = whatever ?
<taniwha> yeah
<taniwha> er, except, there's a better way
<taniwha> transform.SetParent (parenttransform, true/false)
<taniwha> SetParent gives you more control over the coords
<taniwha> iirc, the param is useWorldCoords
<taniwha> rxform.SetParent (plaque.transform, false); from EL
<taniwha> RectTransform rxform = go.transform as RectTransform;
<taniwha> (last two lines reversed)
<Sigma88> thanks
<taniwha> you're welcome. I hope it helps
<Sigma88> the problem is, I don't even know what is breaking :D
<taniwha> the RectTransform stuff is for 2d ui stuff
<taniwha> Debug.LogFormat is your friend :)
<Sigma88> as far as I can tell
<Sigma88> when Kopernicus makes a clone of Kerbin
<Sigma88> it also clones the KSC stuff
<Sigma88> which messes up KSP since it only expects to find one
<Sigma88> the funny thing is that if the game bugs out only if the kerbin clone is closer to the sun than the home planet
<taniwha> ok, so yes, when you clone, you'll need to dig through the clone and remove or rename the ksc stuff
<taniwha> that's not all that funny when you think about it
<Sigma88> that's funny because it means that squad probably uses "First"
<taniwha> if the planets are listed in order of distance from the sun, then the closest one will be found
<Sigma88> assuming there's only one
<taniwha> and the search will stop there
<Sigma88> yup
<taniwha> anyway, when cloning, remove or rename the ksc stuff
<Sigma88> that's for thomas to do
<Sigma88> I don't really understand that part of the code
<Sigma88> but I think as a temporary bodge I can try to reparent the KSC object to Kerbin
<Sigma88> maybe that works
<taniwha> just dig through the clone's hierarchy looking for KSC
<Sigma88> that's what I'm doing
<Sigma88> the problem is that when I get there KSP already has decided that the clone is the proper KSC
<taniwha> and when do you get there?
Thomas|AWAY is now known as Thomas
<Sigma88> I'm trying a different approach now
NotFrom4chan has joined #kspmodding
<NotFrom4chan> ay
Pap|Away is now known as Pap
<NotFrom4chan> ASET seems to be broken for whatever reason. the Flip-Up HUD causes a JSIvariableAnimator initialization failure
NotFrom4chan has quit [Quit: http://www.mibbit.com ajax IRC Client]
Ezriilc has joined #kspmodding
smoke_fumus has joined #kspmodding
ferram4 has joined #kspmodding
regex has joined #kspmodding
tfool has quit [Read error: Connection reset by peer]
regex has quit [Ping timeout: 201 seconds]
Thomas is now known as Thomas|AWAY
regex has joined #kspmodding
blowfish has joined #kspmodding
regex has quit [Remote host closed the connection]
smoke_fumus has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]