Jump to content

Virgin Kalactic -- AdvGenerator, TrackResource, and now NodeToggle!


Greys

Recommended Posts

Virgin Kalactic is a collection of small code projects providing specific features. Composed in VK are several plugins

BetterPart.dll

-Provides expansions to the stock Part class

-TrackResource class offers last-frame resource consumption and generation data

-To access you need a vessel reference, then do the following

 TrackResource tr = DictionaryManager.GetTrackResourceForVessel(vessel);
double consumption = tr.GetConsumption("NameOfResource");
double generation = tr.GetGeneration("NameOfResource");

I highly advise creating some sort of averaging mechanism because these values can be very different every frame

AdvGenerator.dll -- Dependent on Better Part

-Provides AdvGenerator partmodule

-Resource generator that takes an Input and puts out an Output throttled by how much of Output is being consumed by the vessel at that time.

-AdvGenerator is a partmodule, so to use it you add it to a part


MODULE{
name = AdvGenerator

//How many samples to remember and average; more samples makes it move smoother but less responsive.
//There are 50 frames, therefore 50 samples, per physics second, so 75 is 1.5 seconds
numSamples = 75

//This defines the idle speed, the lowest operational rate that the engine can achieve, this generator is intended to never run for free.
//0.002 = 0.2% throttle
minThrottle = 0.002

// INPUT block defines an input resource; the system is designed to accept multiple inputs and multiple outputs, but I haven't tested it much
INPUT
{

//The resource to be input
resourceName = InputResourceName

//The maximum amount of this resource to be consumed during one physics second (50 frames)
maxRate = 0.0025

//The rateCurve block defines how the amount of this resource shifts relative to throttle percent
//rateCurve goes from 0 to 1, at 1 the generator is consuming maxRate of the resource every second
rateCurve
{
// X, Y, In Tangent, Out Tangent
key = 0 0 0 0
key = 1 1 0 0
// These two keys will make a straight line, it works in the same way as engine curves
// You can use this to make the engine more or less efficient at different points
}
}

// Output blocks define the resources to be output, again you should be able to have multiple outputs, but I haven't tested it properly
OUTPUT
{
resourceName = NameOfResource

// Again, maxRate is how much of this resource will be put out per second at 100% throttle
maxRate = 5

// This is important, you can have one primary resource in the generator, and that will be the resource the generator is attempting to satisfy
// If your primary is ElectricCharge, the generator will vary the throttle in an attempt to produce as much as is being consumed
type = PRIMARY
}
}

VirginGeneric.dll

-Provides NodeToggle partmodule

-NodeToggle allows the user to toggle the availability of AttachNodes in the Editor individually

TRMJinfoitems.dll --- WIP, will lag your game

-Provides infoitems for MechJeb's custom window system that read out the current resource con/gen

-Only works for ElectricCharge currently

-Updates every physics frame currently

-Finished plugin will dynamically add infoitems for all resources that currently exist in the game

-Finished Plugin will update once or twice per second, reducing the induced lag by 50-25x

VirginAnimators.dll --- Placeholder, currently no work has been done on this plugin

-Will Contain BalloonAnimator, drive a part through an animation based how much of a given resource container is filled

-Will Contain DustTrail effect, spawn particle effects from wheels based on torque and speed

-Will Contain JointLink, will toggle the visibility of a specified gameobject based on if a given attachnode has a part connected to it

NodeFix.dll --- Abandoned Project, free to good home

-Attempts to correct the glitch with stock KSP where AttachNodes defined via the NODE{} structure always have a size of 1.

-Unfortunately due to another bug where PART ConfigNodes stored in the GameDatabase are stripped of string values such as the part's name, and the node's name, making it impossible to associate stored data with the AvailablePart pool

-The remaining way to make this plugin work would be to reparse all the cfg files for NODE{} nodes, and I just don't want to.

-The problem this plugin attempts to solve and the reason I couldn't solve it have both been fixed in the up coming KSP 0.24 release, so there is little value in the amount of work it would take to fix it for 0.23.5

-NodeFix is available under the MIT license, if anybody wants to put in the effort they are free to do so.\

NodeFix has been removed from the solution on the github repo, but the project is still present in it's directory

All of the above can be found on the github repository:

https://github.com/Greys0/Virgin-Kalactic

Specific assembled releases can be found here:

https://github.com/Greys0/Virgin-Kalactic/releases

Releases contain other required mods such as ModuleManager and CrossFeedEnabler

These are not included in the repository, so if you choose to install from the repository master download you will have to obtain these for VK to operate correctly.

Specifically, BetterPart and NodeToggle rely on ModuleManager, and AdvGenerator relies on CrossFeedEnabler; without CFE you will have to link the generator module with fuel lines.

Unless specified otherwise all components of this mod are All Rights Reserved, until I feel like doing the research to understand more open code licenses.

If you want to do anything with components of this mod, please contact me, I'm very open most of the time.

If you have any problems please let me know, and if you have any suggestions on how to improve the code I'd be glad to hear, I'm not exactly good at this

Special thanks to Ferram, EggRobin, NathanKell, Majiir, Stupid_Chris, SirCmpwn and anybody else I can't feel my brain but I wouldn't have gotten anywhere without yall's help

Edited by Greys
Link to comment
Share on other sites

This mod for Kerbal Space Program adds in a system to permit the tracking of resource use throughout a vessel, and then uses that to impliment a responsive fuel burning engine.

Umm... can you maybe... deobfustucate that somehow? In what way is the resource use tracked? How is it different from stock? Does a responsive fuel burning engine respond to something, or is the fuel responsive? What is it responding to?

Link to comment
Share on other sites

Umm... can you maybe... deobfustucate that somehow? In what way is the resource use tracked? How is it different from stock? Does a responsive fuel burning engine respond to something, or is the fuel responsive? What is it responding to?

Without getting too technical (if you want to get technical the code is pretty obvious), BetterPart replaces Part (aka PART{module=Part} in a cfg file) but inherits all of Part's functionality, I've then overwritten RequestResource() so that I can capture all the values passed to it by things that consume or create resources, such as engines and solar panels; from there I pass the request to the original RequestResource() to be carried out. With the plugin installed and the ModuleManager patch complete, every resource consumption or creation that doesn't bypass RequestResource(), which would be everything except TAC FuelBalancer, Interstellar Mod, and maybe TAC LifeSupport, will automatically be recorded on a frame by frame basis.

From there the AdvGenerator PartModule keeps a record of the last 20 frames worth (configurable in the part's .cfg) and averages it to determine how much of the output resource is being consumed ship wide. It then determines how much it needs to generate to compensate for that based on the curves in the cfg file, and how much input resource that would cost; finally it puts in all the necessary requests.

I'm still working on balancing everything, currently it doesn't quite add up and the vessel loses charge over time; also the included generator is /very inefficient/, I'm working on that too.

Link to comment
Share on other sites

Okay, I think I get it.

Let's use a popularly recognized base resource: kethane. Say I have a vessel with a big kethane tank. With this mod, that vessel could have an onboard converter (I suggest not calling it a generator because that makes people think of electricity), and that converter could be configured to transform kethane into monopropellant, liquid fuel, and oxidizer. The magic in this particular mod, the thing that's different from the existing resource converters, is the vessel is smart enough to convert kethane into other resources on demand, in response to usage. Expend 5 units monopropellant, and the converter will produce 5 units monopropellant. The player doesn't have to babysit the whole operation to make sure the tanks are full.

Do I have it right?

Link to comment
Share on other sites

v1.1 fixes 2/3rds of all the game breaking bugs!

actually the only game breaking bug is the one that breaks timewarp, and it remains. Will hopefully be fixed soon but v1.1 makes it work correctly besides that

https://github.com/Greys0/Virgin-Kalactic/releases/tag/v1.1

Edit: update on timelines, I'm off vacation now and back to work, I will still be trying to solve this adequately in a timely fashion but I don't expect to fix it before monday.

The issue at hand is that DictionaryManager watches for when vessels come on and off rails to manage that vessel's TrackResource instance, which means that when you go into timewarp, the TrackResource gets deleted; and then when you leave timewarp a new one gets created. The obvious solution to this is for AdvGenerator to also watch for timewarp happening and get the new one; but this means that AdvGenerator cannot operate responsively during timewarp. I could have it not work at all, or I could have it pick a level to continue running at during timewarp, but neither are solutions I'm willing to accept. Currently I'm trying to find a different set of things for DictionaryManager to watch; luck hasn't been good so far.

Edited by Greys
Link to comment
Share on other sites

Tentative success!

https://github.com/Greys0/Virgin-Kalactic/releases/tag/v1.2

Again, if you have any trouble with this please let me know immediately, but I think that this is now fully functional from a plugin standpoint. Clearly the configuration of the generator needs some work; at an idle it seems to be burning fuel so slowly as to negate the meaning of burning fuel at all, and the way the throttle controller operates is not what I'd like. In the long run I want to have a flywheel system where the mod has an RPM, and based on the RPM value, a draw value, and an engine mechanic; where the RPM defines the amount of energy available, the draw value pulls energy out of the flywheel at a certain rate, thus reducing the flywheel's RPM; and the engine mechanic then responds to keep the RPM's stable. I have no idea how I'm going to go about that; or if. In more attainable goals I need to add a secondary throttle logic that will account for the battery capacity of the vessel and boost the throttle in order to rebuild the buffer; where currently it just produces slightly more than the ship needs to counter floating point inaccuracies and rounding errors. The buffer maintenance logic will make this unimportant by periodically boosting output when under a certain percentage.

Anyways, posting this now~ *goes to play space engineers*

Link to comment
Share on other sites

  • 3 weeks later...

Nothing happened, but here have a new version anyways.

https://github.com/Greys0/Virgin-Kalactic/releases/tag/VK_v1.3

I've typed this a few times already so just read the release notes and commit notes for more details, but basically I've rearranged all the code, renamed files, separated things, now there's 3 times more dll than before, there's more goals and stuff so I'll probably be working on this more frequently again.

On the down side, we've entered heatwave season here, so my productivity and moreso ability to play KSP for testing purposes has been largely restricted, we'll see how problematic this is.

So the big thing that changed is a change made specifically to support other modders. I moved BetterPart, DictionaryManager, and TrackResource into their own DLL, so you can now use that by itself without having to worry about my other stuff surrounding it. All that other stuff is now in other DLLs. Now I do want to allow people to distribute BetterPart.dll with their own projects, but I'm not quite in the mindset to be reviewing licenses and getting all that sorted so for the time being if you would like to use it ask me and I'll give you specific license.

Anyways, bed time now~ *goes to sweat in bed*

Link to comment
Share on other sites

Lots happened, my brain hurts, already in bed; significant updates.

https://github.com/Greys0/Virgin-Kalactic/releases/tag/VK_v1.4

This is exclusively an update to AdvGenerator, but it's important.

As always, if you have any issues tell me ASAP.

Probably won't be another update till friday at the soonest, but I haven't the slightest idea how to do what I want to do next so whatever.

Link to comment
Share on other sites

  • 4 weeks later...

New project! actually lots of new stuff, I'm not even going to summarize but today I made a thing that lets you toggle attachnodes per part in the editor.

This Is Not Done

This Is Not Perfect

This will fill your logs with nondescript errors that I'm pretty sure KSP is putting out but your guess is as good as a goat

This does however appear to generally work!

Introducing VirginGeneric.dll, which contains the NodeToggle partmodule; this partmodule is applied to all parts via ModuleManager at start.

In the VAB or SPH right click on any given part and you will be presented with a bunch of ugly options to disable all the nodes present on that part.

Clicking the button will make that node go away while in the editor; if the node is already in use it does nothing, actually it still does that but it doesn't matter because the AttachNode has been replaced with a joint anyways.

Clicking it again will make the node come back; I haven't tested what will happen if the part is already attached when this happens so.....

There is a label for the state of the node, this label doesn't seem to update correctly, and looks bad anyways. Gonna fix that.

I have experienced some issues with nodes that have the _000 numbering system appearing to be the same thing, I'll have to identify the nodes in a different way and I think there's a hash I can access that will be unique. Unfortunately this means that my dear hexcans don't quite work right with it, one end node and the side node are thought to be the same so only the bottom node can be toggled. This will get fixed.

Why? Frequently I end up with tight nit structures where there are nodes all over the place and it gets difficult to attach something to the correct place, or small parts that have several nodes on them which are too close together. With this you can turn off the nodes you don't want to allow the desired assembly. It also lets me put more nodes in the same space and with this functionality not worry that it will be unuseable. Anybody who's wanted hescans to have six sidenodes, once NodeToggle is cleaner, and 0.24 comes out with the fixed NODE{} size....ness, I intend to add those additional nodes.

If anybody experiences any problems they should probably tell me about it so I can fix it.

I'm not going to make a full release for this, just download these two files and put them in /GameData/Virgin Kalactic/

https://github.com/Greys0/Virgin-Kalactic/blob/master/GameData/Virgin%20Kalactic/VirginGeneric.dll

https://github.com/Greys0/Virgin-Kalactic/blob/master/GameData/Virgin%20Kalactic/Patches.cfg

Link to comment
Share on other sites

Release time!

VK v1.5, introducing VirginGenerics.dll v0.3

https://github.com/Greys0/Virgin-Kalactic/releases/tag/VK_v1.5

I know I do this thing where a bunch of stuff happens all at once and then nothing for a while, but after sleeping I was able to fix the problems with nodes having the same name.

Nodes are now identified by their hashcode, this should mean that each one is unique within reasonable considerations. Unfortunately I'm not able to correct any situation where two nodes end up having the same name, so they will be shown as having the same name. Complain to whoever made your parts. HexCans suffer from this, I will be correcting it.

Link to comment
Share on other sites

All your plug-in looks good, maybe you can improve them a little bit by adding more documentations and examples, for example, reading the BetterPart description wake my interest but I have not a single clue on how I have to use it and most importantly why I should use it instead of stock Part module, it's better and ?

Link to comment
Share on other sites

  • 3 weeks later...

Updated~ That was pretty easy but I'm tired so it took a couple hours longer than I intended. No change in features, just making sure everything still works.

As KSP 0.24 is now released, NodeFix should now be entirely pointless; I will be deleting it at some point in the future but it will always remain available through Github's history.

Update can be downloaded here https://github.com/Greys0/Virgin-Kalactic/releases

Link to comment
Share on other sites

  • 3 weeks later...

Update~, little change, recompile against 0.24.2, updated ModuleManager and CrossFeedEnabler in the release download, and updated ALL THE LICENSES~

There's one more change that I need to make the license and that's write it into BetterPart's license that it may be included unmodified without specific authorization.

As always, download here: https://github.com/Greys0/Virgin-Kalactic/releases

Link to comment
Share on other sites

  • 4 weeks later...

Hi! It seems like your framework it's beeing used into the new release of B9 by Taverius :cool:.

I've asked him the chances of having the extra nodes in the new parts disabled by default in order to make ship building easier but it seems (I've been reading your code) that Virgin Kalactic cannot do that at this moment. Have you thinked of adding this feature to your work?

Thank you very much for making KSP even better than it is!

Link to comment
Share on other sites

That would take a pretty significant modification of the workflow, but I'm not against it.

As it is every part has an object which contains all the AttachNodes, what NodeToggle does is copy that object into itself, and then based on user input delete AttachNodes from the part; when the user enables them again it takes the copy it made and puts it back. Tav has asked me about making it remember when they've been disabled and the feature you're asking for would go hand in hand with that; I would need to add a new thing, probably a list or dictionary of binary values. It's doable, I can see exactly how, I'm not certain I will do it any time soon and I can say that adding the code to load state designations from the cfg file might double the amount of code.

Life is complicated, I just took the tire off my car, took it to the gas station to refill it with air, and put it back on; hopefully in the morning it's still full. Point is, the time I can spend on games and games related activities is much smaller than the time I do spend, and life is starting to pull back it's foot.

So, reviewing some things, I wanted to conclude this with a message that VirginGeneric.dll is effectively MIT license so I checked to see how I had modified that and I was very confused to find that it is not, I must have messed up with that. I'm a bit tired but I have monday off and I should have it fixed then. As a holdover in case I forget or somebody wants to add the feature tomorrow (today (sunday)):

I hereby grant Bac9, Taverius, K3|Chris, and anyone authorized by them the rights to modify, compile, publish, and distribute the source code of VirginGeneric.dll provided the terms of the public license are fulfilled. Derivative versions of VirginGeneric.dll released while this license is valid will be permitted but not required to operate under this license indefinitely. This license will be rendered null and void at the time that the Public License pertaining to this source code and binary is updated to be less restrictive.

Public License as of this posting: https://github.com/Greys0/Virgin-Kalactic/blob/43915239202aa003b921b12d1476a6ab4f6875b7/Source/Virgin_Kalactic/VirginGeneric/LICENSE

Most current Public License (same thing as of this posting): https://github.com/Greys0/Virgin-Kalactic/blob/master/Source/Virgin_Kalactic/VirginGeneric/NodeUtilities.cs

I say permitted but not required because I expect that the wording of whatever license I end up assembling will be more open then what I've authorized above, and it will certainly be more clear.

I also want to be clear on my opinion of licensing mods. I feel that any plugin which patches a bug in the base game and nothing else, or adds a very small feature, should be released under very open terms, MIT/BSD where possible. Because of potential legal conflicts I strongly suggest against bug patches being GPL; I feel that the terms that KSP is sold under may directly circumvent GPL being used in certain ways, but people will still try and that dispute over the base game being fixed is bad for everyone. GPL is fine for larger projects which are incredibly unlikely to be 'bought' by Squad, or 'inspire' similar features which sufficiently resemble the GPL content that it would be a problem. The smaller your feature is the fewer ways there are to achieve it, and I feel that also circumvents GPL claims in the same way you cannot trademark "the". The one exception to being open is where openness potentially induces conflicts. BetterPart is All Rights Reserved because there can only be one BetterPart in play in a given instance of KSP at any given time, if there were a fork of BetterPart, the existence of 2 directly reduces both. I would however like to say that I have been working to rewrite BetterPart to be an event based system that any plugin can register with, and will in the long run be overhauling TrackResource with similar systems that will hopefully provide a lot of the base features that are generally wanted alongside in an event based system. I'm rambling and I've spent over an hour composing this. Just want to say that last time I worked on the update to BetterPart I got to a point where it looked like it worked, but then this happened

UFpfGXtHThwL.png

Link to comment
Share on other sites

  • 1 month later...
Guest Space Cowboy

NodeToggle?!

This could be big for me.

When I was building the stock Millenium Falcon I ran into a node problem tring to install a VTOL engine cluster inside. I was basically in node hell. Will be trying this later.

Link to comment
Share on other sites

There is a recompile already, B9 team has it; I'll be pushing a release but I spent all of friday, and then a lot of saturday, and some of thursday... and... moving on; working on HexCans; and I made huge progress on that, got the NODEs working; in fact I'd say I have every part functionally updated at this point. (unfortunately I still need to complete some remodelling I did and then update all of the textures. All of the Textures. God kill me now. To the new and improved models.

Also I've completely rewritten everything in Virgin Kalactic except for NodeToggle, which didn't change at all; and SrFix, which had a 2 line changes; and AdvGenerator; which must now be updated to all the things that changed..... Maybe tuesday?

In the mean time, I suspect that the most recent release will generally operate fine; NodeToggle should be fine though it may throw more errors than normal, SrFix is on KerbalStuff

Link to comment
Share on other sites

Greys, figured I would share what I have done to NodeToggle. Now users can SEE what attachnodes will be disabled/enabled from the menu. I'll send you the code when I have a free moment but here's a video(ignore the glitchy graphics issue, i didn't have all B9 required plugins to work):

Link to comment
Share on other sites

  • 2 months later...
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...