Jump to content

The official unoffical "help a fellow plugin developer" thread


Recommended Posts

8 minutes ago, AmpCat said:

 


    //[KSPAddon(KSPAddon.Startup.MainMenu, false)]

 

Don't comment this line out. It's what's known in C# as an attribute, and it tells KSP that it should load your class as an add-on. Once you remove the '//' you should start getting more interesting results.

Link to comment
Share on other sites

Just now, HebaruSan said:

Don't comment this line out. It's what's known in C# as an attribute, and it tells KSP that it should load your class as an add-on. Once you remove the '//' you should start getting more interesting results.

Oh, I only just commented that out to see if it would change anything. It didn't. Same behavior either way.

Link to comment
Share on other sites

17 minutes ago, AmpCat said:

I'm trying to start learning to mod, and I've gotten kind of stuck on a simple 'Hello World'.

HebaruSan was faster than me for the KSPAddon but the HelloKerbinMod should work as a PartModule. Can you show the CFG you used ?

Edited by sarbian
Link to comment
Share on other sites

	// --- internal setup ---
	CrewCapacity = 1
	tags = #autoLOC_500321 //#autoLOC_500321 = capsule cmg control ?eva fly gyro ?iva moment pilot react rocket space stab steer torque
	INTERNAL
	{
	  name = mk1pod_IVA
	}
	
	MODULE
	{
		name = HelloKerbinMod
	}

	MODULE
	{
		name = ModuleCommand
		minimumCrew = 1
		defaultControlPointDisplayName = #autoLOC_6011003 //#autoLOC_6011003 = Default
		CONTROLPOINT
		{
			name = reverse
			displayName = #autoLOC_6011004 //#autoLOC_6011004 = Reversed
			orientation = 0,0,180
		}

	}

I stuck it into the default mk1 crew capsule here. I just copied the bit of that code and around it. It seemed a little sparse, but that's how I understood it from the tutorial.

Link to comment
Share on other sites

I'm trying to publish it the VS project on github (not sure if that's really the best way to do it), but in the meantime:

https://drive.google.com/drive/folders/1bkDjVVgZh7I3Qcs24KXr4kOSCgQ9fa7C?usp=sharing

That's the DLL.

Here's the github link, if it's helpful: https://github.com/AmpCat/KSP-Hello-World

 

Edited by AmpCat
Link to comment
Share on other sites

7 minutes ago, AmpCat said:

I'm trying to publish it the VS project on github (not sure if that's really the best way to do it), but in the meantime:

https://drive.google.com/drive/folders/1bkDjVVgZh7I3Qcs24KXr4kOSCgQ9fa7C?usp=sharing

That's the DLL.

Here's the github link, if it's helpful: https://github.com/AmpCat/KSP-Hello-World

 

I don't actually see a helloworld.cs file with the code.

 

Link to comment
Share on other sites

I would change the following in the .csproj:

    <Reference Include="UnityEngine">
      <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
    </Reference>

to:

    <Reference Include="..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine*.dll"</>

I am believing you are compiling for 1.8 - and some .dll were split up - and you seem to be missing the UI part. :D

do you know how to set an environmental variable?

if so - set one to the KSP_x64_Data/Managed/ directory (call it DEVDLL or something.)

replace all the

..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed

with

$(DEVDLL)

notice - no spaces and need the \UnityEngine*.dll (or whatever) at the end.

 

Edited by zer0Kerbal
Link to comment
Share on other sites

There is no UI so it does not really matter and it compiled so the required refs were there.

Your dll works fine here.I get the "Hello world!" with the time.  Did you wait until you reached the main menu ? It is set up to run only in there ( KSPAddon.Startup.MainMenu )

Or it could be an over zealous anti virus. 

Link to comment
Share on other sites

I'll check in the main menu again. Oh, there it is now. Huh. I wonder which of the million changes fixed it. I thought it would only show up on the flight menu or something, so for a while I wasn't checking on the main menu.

Course, doesn't explain why the part module doesn't work.

Edited by AmpCat
Link to comment
Share on other sites

asking for assistance:

simple bit of code: need to run through three lists and multiple each value by a constant. I believe foreach is the optimal way to do this, just don't know C# and the KSP API well enough to do this.

definitions:

/// definitions
public struct Fuel
{
	public int resourceID;
	public float rate;
	public ResourceFlowMode resourceFlowMode;
}

public struct mode
{
		public Fuel[] fuels, byproducts;
		public Double maxEC;
}

pseudocode:

// Actual Code:
internal void OnRescale(TweakScale.ScalingFactor.FactorSet scaleFactor)
{
	/// this scales any resources on the part with ODFC:
	foreach (PartResource resource in this.part.Resources)
	{
	resource.maxAmount *= scaleFactor.cubic;
	resource.amount *= scaleFactor.cubic;
	}

	/// this scales the actual fuel cell, fuels, byproducts, and maxEC
	// below is pseudocode:
	foreach (Fuel fuel in fuels) *= scaleFactor.cubic;
	foreach (Fuel fuel in byproducts) *= scaleFactor.cubic;
	foreach (Fuel fuel in maxEC) *= scaleFactor.cubic;

	// calls module updater
	this.updateFT();
}

 

Link to comment
Share on other sites

3 hours ago, AmpCat said:

And now it's broken again. I went to change it to 'Start' instead of 'Update', and it didn't work, so I changed it back.. now it doesn't work either.

Okay, I was able to randomly fiddle with things I've tried before, and got it working again; I switched the .NET target to 4.0, rather than 4.7.2, and now both parts of my hello world work. And, as one might expect, I no longer get the error it can't find that Module.

I read here, and it says we should be able to use any 4.x .NET framework, though. So what's the real answer?

Edit: Okay, now I'm real confused. I went back and tested other .NET frameworks to see which worked and which didn't, and now even 4.7.2 works. I'm very confused. I don't know what is messing up.

Edit2: Annnnd, can someone help me figure out GitHub (again)? Just looking for a volunteer to help me figure out how to take my local files and make the github repo online match. I don't know why this is so hard. :P

Edited by AmpCat
Link to comment
Share on other sites

Wrong thread disregard ^^

Spoiler

 

Hi,

For some reason NetKAN bot didn't catch my Chatterer updates (v0.9.98 for KSP1.8 and v0.9.97 for KSP1.7.x) yesterday.

https://github.com/KSP-CKAN/NetKAN/blob/master/NetKAN/Chatterer.netkan

My other mod update for LCDLaunchCountDown worked flawlessly tho 

https://github.com/KSP-CKAN/NetKAN/blob/master/NetKAN/LCDLaunchCountDown.netkan

Should I do something ? Thx.

 

 

Edited by Athlonic
WTOD - wrong thread of death
Link to comment
Share on other sites

59 minutes ago, Athlonic said:

Hi,

For some reason NetKAN bot didn't catch my Chatterer updates (v0.9.98 for KSP1.8 and v0.9.97 for KSP1.7.x) yesterday.

https://github.com/KSP-CKAN/NetKAN/blob/master/NetKAN/Chatterer.netkan

My other mod update for LCDLaunchCountDown worked flawlessly tho 

https://github.com/KSP-CKAN/NetKAN/blob/master/NetKAN/LCDLaunchCountDown.netkan

Should I do something ? Thx.

https://github.com/KSP-CKAN/NetKAN/issues/7444

Link to comment
Share on other sites

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