Jump to content

[0.20.2] Resource Generation Module (0.28)


Fel

Recommended Posts

@devanmedrow: I've thought about it... and thought... and thought....

KSP only has "Temperature" as a static value, there is no real "Heating" system (Heck, engines can "overheat" in space, but turning them off almost instantly dissipates all that heat "magically").... and with "Heating" comes reentry heat, even checking if a part is facing the sun.

Implementing "Heating" becomes a mod in and of itself.

@ahd1601:

This is a "Not A Programmer" plugin. (And yes, it is fairly sloppy because no one debated language standards with me (i.e. how to treat "killPartKerbal", it really is a function but I want to keep a simple interface)... and I also want a way to switch back from "else" but I have no idea how to implement that using the current interface.).

You can "create" things with it; Right now it is mostly focused on what people have suggested, Air breathing RCS, Lifesupport... if I went back and got latitudes and longitudes implemented you probably could create mining mods with it as well... but it is not really a mod in and of itself. Now I am giving a large amount of power to the "Not A Programmer" user, or even to the programmer who doesn't want to write the plugin; but as a "create your own mod" plugin, I can understand why people aren't that interested.

@SciMan:

Oh... wait... of course! Xenon isn't a freeflow element.

Yep, that solved it!

RESOURCE_DEFINITION
{
name = XenonGas
density = 0.0001
flowMode = ALL_VESSEL
transfer = PUMP
}

Or connect a "fuel line" to the rcs port.

(Maybe I really should add in those overrides...)

Edited by Fel
Link to comment
Share on other sites

@SciMan:

Oh... wait... of course! Xenon isn't a freeflow element.

Yep, that solved it!

RESOURCE_DEFINITION
{
name = XenonGas
density = 0.0001
flowMode = ALL_VESSEL
transfer = PUMP
}

Or connect a "fuel line" to the rcs port.

(Maybe I really should add in those overrides...)

... hold the phone, XenonGas is ALREADY a freeflow element in the stock game. IIRC, it works like monopropellant because so long as both an ion engine with enough power and a Xenon tank that isn't empty are both on the same ship, the ion engine will work.

The resource definition code I posted is for the CUSTOM RESOURCE called "XenonIons" that I defined in a separate file. It's set for NO_FLOW because it is supposed to get generated by the same thruster that uses it, therefore because it doesn't NEED to go anywhere, I made it so it CAN'T go anywhere.

Wait a second, I just remembered something that might be important. Does this plugin do anything odd if you set the output generation rate to be greater than the resource's maximum storage capacity? If so, that would be what my problem was, because I did exactly that when I was testing, then I noticed that the thrusters weren't nearly as "thirsty" as I had thought they would be, while simultaneously discovering that the thrusters were not being refilled!

Link to comment
Share on other sites

Really, that "transfer = PUMP" does fix it...

To quote the default ResourcesGeneric.cfg

RESOURCE_DEFINITION
{
name = XenonGas
density = 0.0001
flowMode = ALL_VESSEL
transfer = NONE
}
RESOURCE_DEFINITION
{
name = MonoPropellant
density = 0.004
flowMode = ALL_VESSEL
transfer = PUMP
}

It should ALWAYS fill an empty tank and NEVER fill a non-empty tank... and "rate" is just how much it will take to produce the other resource. (I got confused for a second while trying to figure out what was wrong with what looked right).

*Source wise, AmpYear's only difference is "fuelCrossFeed = True (located outside the "module" nextto mass="" (The RCS Module is only for interfacing). And that does it :P

Edited by Fel
Link to comment
Share on other sites

Ok, I'm really intruqued by this, but I think I'm too tired cuz I'm not understanding how to use it.

How do I do conditionals with this? does it have that?

How do I use up a water resource if ResGen.AtmosphericOxygen and ResGen.Sunlight, and have it output food?

Link to comment
Share on other sites

i understand the not getting in to part Temperature issues. You are right it would be to much to try to add to this plug-in.

Would you be able to setup a module to allow you to transfer a "Resource" from the part it is in the cfg file of to a part of your chose. In game right click or set in config. It transfers at X speed a sec, and stops transferring when the receiving part gets to X% or X#.

I could then add the already added modules to slowly bleed off "Resource A" at X per sec.

When "Resource A" gets to "0" craft become inoperable or just starts "Timer 1". When timer 1 hits "0" Kerbals die.

It could show up like fuel in a fuel tank. Life support in space is:

Pressurized hull, Heat

Power

O2, CO2 Removal

Water, Food, waste removal.

If this is still not what you would like to do... Ok.

I could probably set it up so "Heat" as a fuel like mono propellant just with a mass of "0.0000000001". Let the "Thermal generator" ResGen a fuel "Heat". Ane the crew pods store fuel "Heat", but they also use "Heat" at about 0.01 a second.

Would it be possible to change the cfg file of a solar panel so it make resource "heat" not power. And to add to that solar panel a Temperature map (the red glow on rockets when they are hot). Set the Temperature map in cfg file to glow based off the amount of resource "heat" it is making???

thank you for your time and patience

Link to comment
Share on other sites

Okay, I believe that could work out (Uhh, tired so haven't fully comprehended the second part).

I am "strongly considering" doing a bit of a rewrite and forming my own "resource map" which would allow me to bypass the "RequestResource" to do "Really Cool Things that I said on some other page"

*err, tired XD

Eitherway, It would be feasible to add in some kind of "Target THIS partname" on the INPUT / OUTPUT (inputs drain from x partname, output put out to x partname)...

Link to comment
Share on other sites

Would it be possible to change the cfg file of a solar panel so it make resource "heat" not power.

I would like to make a deployable solar panel a Thermal radiator. a liquid is pumped though the panel and the sun heats it up. the liquid now goes it to the crew cabin heating the air to a Kerbal friendly temp.

And to add to that solar panel a Temperature map (the red glow on rockets when they are hot). Set the Temperature map in cfg file to glow based off the amount of resource "heat" it is making???

This would be something that would have to be changed in the model first.

A rocket engine has a model, texture, and a glow texture. the last one shows the rocket bell glowing when the rocket is getting hot. This part of the question is there a way to have the glow texture show with out messing with the real heat of the rocket part?

Link to comment
Share on other sites

Update on my quest to make some Ion RCS thrusters with this plugin:

I was so sure that I was doing things right that I decided to test the B9 "compresed air" RCS thruster to make sure that they were still working.

I built a simple ship (intake, probe core, battery bank, RTG, B9 Air RCS) and guess what? Same problem: ResGen is installed but non-functional.

This means I have a plugin conflict on my hands. Not sure if I wanted to be "correct" on that part.cfg syntax after all......

Well, at least I can attempt to help narrow down what plugins could be causing the issue.

KAS, MechJeb2, and Kethane I ruled out because I was running them when I installed the B9 pack (the B9 air RCS worked then), and the other plugins from the B9 pack are exempt because they wouldn't be in the pack if they caused problems.

However, I did recently install TT Modular Multiwheels 0.5 and the RubberBand Inc Track pack, both of which have plugins, and I only noticed the parts not working AFTER that.

The coder for the track pack is EndlessWaves, and TouhouTorpedo is the coder and author of the Modular Multiwheels pack.

Hopefully a conversation between those two coders and yourself (@Fel) will be able to resolve the code conflict.

Until then, I'll just have to make do without the functionality of ResGen. Not a big setback - but it does kind of neuter my idea for fully-electric propulsion based space tugs and pinpoint accurate translational thrust for station-keeping of larger probes.

Link to comment
Share on other sites

It would be feasible to add in some kind of "Target THIS partname" on the INPUT / OUTPUT (inputs drain from x partname, output put out to x partname)...

That would be great INPUT could be used for cooling reactors and rockets off.

OUTPUT could put "resource" directly into the part it is mounted to.

Right now i'm looking at

part 1: solar radiator

resgen

{

if resgen.Sunlight = 5

{

output = 1 Kelvin heat per secant

}

}

Part 2: Crew Moduel

Fuel copasity: "Kelvin Heat" = 295

{

ResGen

{

INPUT = .5 Kelvin heat per secant

INPUT = 1 O2 Air per Kerbal in part per secant

INPUT = 1 food per Kerbal in part per hour

INPUT = 1 Water per Kerbal in part per hour

OUTPUT = 1 Wast per Kerbal in part per hour

OUTPUT = 1 Co2 per Kerbal in part per secant

}

if Kelvin heat <= 255

{

disable craft

stop timer2

reset timer2

start timer1 (4 hours)

}

else

{

start timer2 (2 hours)

stop timer1

Timer1 = 0

{

kill kerbals in part

}

Timer2 = 0

{

reset timer1

}

}

I know this is not exactly the right code for this but I'm working on it.

or i could have a reactor heat the crew cabins and hydroponics bays. Then have coolant radiators cool the rest of the reactor down. If I forget to open the radiators

Part 3: nuclear reactor

Fuel copasity: "Kelvin Heat" = 533

{

if kelvin Heat = 533

{

ResGen.Explode (Trying to see if this can destroy a lot of parts)

}

}

did a little looking up:

Kelvin 0 is about -460 Fahrenheit / -273 Celsius

Kelvin 230 is about -46 Fahrenheit / -43 Celsius

Kelvin 255 is about 0 Fahrenheit / -17 Celsius

Kelvin 273 is about 32 Fahrenheit / 0 Celsius

Kelvin 295 is about 72 Fahrenheit / 22 Celsius

Kelvin 340 is about 153 Fahrenheit / 67 Celsius

Kelvin 366 is about 200 Fahrenheit / 93 Celsius

Kelvin 533 is about 500 Fahrenheit / 260 Celsius

You have been very helpful in making this mod. Thank you very much.

Is it possible to get the amount of "Recourse type" in this part only?

Link to comment
Share on other sites

Okay, I cannot get explosions to "spread"... I'm not sure that they can. The only way I can think of to fix that is to cause the part to "smash" into the center of the vessel... (Technically I added in a ResGen.Detonate... but it doesn't do what I want; just makes a really massive explosion that only affects a single part XD [and even if I walked the nodes... that'd mean that "bundled rockets" wouldn't damage things next to the bundle *GRR*)

After looking over what you were asking for (and once again feeling that reworking the whole fuel transfer system is a painful amount of work [really cool and powerful, yes... but still a large undertaking]), I decided to introduce variables instead. I don't really understand how they work... and probably have errors... I know that the GlobalVar works as that was the basis of my testing... but I feel very lazy now -__-;

@SciMan: THIS WORKS!

I downloaded and ran it just fine with your plugins, and I operate in my own namespace with nothing "out of the ordinary" so I cannot explain why you're having problems... but try this verbatim.

PART
{

// --- general parameters ---
name = RCSBlock
module = Part
author = NovaSilisko

// --- asset parameters ---
mesh = model.mu
scale = 0.1

// --- node definitions ---
// definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z
node_attach = 0.45212, -0.0105571, -0.0059382, 1.0, 0.0, 0.0



// --- editor parameters ---
cost = 450
category = Control
subcategory = 0
title = RV-105 RCS Thruster Block
manufacturer = STEADLER Engineering Corps
description = The recent discovery of a third law of physics made it possible for STEADLER Corps engineers to produce these small monopropellant thrusters, to help with attitude control and linear motion. Even though many Kerbal physicists still dispute the validity of this new law, studies show that the thrusters seem to work as advertised.

// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
attachRules = 0,1,0,0,0

// --- standard part parameters ---
mass = 0.05
dragModelType = default
maximum_drag = 0.001
minimum_drag = 0.001
angularDrag = 2
crashTolerance = 15
maxTemp = 3600
fuelCrossFeed = True

// --- rcs module parameters ---

MODULE
{
name = ModuleRCS
thrusterTransformName = RCSthruster
thrusterPower = 0.125
resourceName = XenonIons
atmosphereCurve
{
key = 0 3200
key = 1 3200
}
}

RESOURCE
{
name = XenonIons
amount = 0.15
maxAmount = 0.15
}

MODULE
{
name = ResGen
INPUT
{
name = ElectricCharge
rate = 7.0
}
INPUT
{
name = XenonGas
rate = 0.032
}
OUTPUT
{
name = XenonIons
rate = 0.032
}
}
}

****

Yes, the language has gotten a fair bit more complex; but that is because of needing to debate language standards. As it stands, I think that I'm going to take a break from this. I'll fix bugs if notified of them, but things got very complex very fast and I know that a large rewrite is practically needed :(

Edited by Fel
Link to comment
Share on other sites

Okay, I cannot get explosions to "spread"... I'm not sure that they can. The only way I can think of to fix that is to cause the part to "smash" into the center of the vessel... (Technically I added in a ResGen.Detonate... but it doesn't do what I want; just makes a really massive explosion that only affects a single part XD [and even if I walked the nodes... that'd mean that "bundled rockets" wouldn't damage things next to the bundle *GRR*)

Thats ok. This is something i think we will have to wait for the devs to add in :(

After looking over what you were asking for (and once again feeling that reworking the whole fuel transfer system is a painful amount of work [really cool and powerful, yes... but still a large undertaking]), I decided to introduce variables instead. I don't really understand how they work... and probably have errors... I know that the GlobalVar works as that was the basis of my testing... but I feel very lazy now -__-;

aging thats ok. I'll just make it so heat flows every where. (Like mono propellant)

Now I'll start building my config files for parts, and new part models.

thank you for your time and patience

Link to comment
Share on other sites

Well what if this module has its own script language (or just use Lua for convenience?) written in a separated file, what you only need to add into the part.cfg is the file path of that script file.

That way the part.cfg will be clean & short while we can edit the script files which will be read in run-time without the need to reload all parts via debug menu.

Also, with script languages, the logic can be really complex. What we need to do is just feed the script interpreter with our real-time game info like the crew count, the sunlight factor, etc... plus several interfaces that can be called by the script to modify values inside the game like the resource count, or to execute some action like killing a kerbal etc...

Edited by HoneyFox
Link to comment
Share on other sites

  • 2 months later...

Can you add a function to turn off the action group when the part is not visible to the Sun, like this:

MODULE
{
name = ResGen
useToggle = true
INPUT
{
name = ResGen.Sunlight
rate = 1
}
ACTIONGROUP
{
groupName = "Lights" \\ name of the action group that will be enabled
resourceName = ResGen.Sunlight \\ name of the consumed resource
isInverted = true \\ if true, automated action group enabling will be inverted
}
}

This is how I imagine the part of .cfg for my automated lantern.

Link to comment
Share on other sites

  • 2 weeks later...

one way you could get the explosion to work partly. Wold be to have the part look at the attachment chain. (C4 part is attached to side of fuel tank01, below fuel tank is fuel tank02, below is fuel tank03, below is rocket buster. above is decoupler 02, rocket buster, fuel tank04, then fuel tank05.

The C4 part applies 80% to fuel tank01, then 80% of that to fuel tank02 and decoupler 02 (the next part above, below, and side attached), then 80% of the last parts damage go to the next part above, below, and side attached to those parts. So on and so on tell every part is hit once, or the damage = 0.

the draw back to this is 2 parts right next to each other but not connected for several parts up would git very little damage.

And if you wonted to go a little extra you could look at what resource is in the parts that get destroyed and and there explosive damage to the mix. C4 blows up an empty fuel tank no big deal. It blows up a full 3meter fuel tank and the damage that spreads from that part out takes out half a station.

disregard this post. Fel talked about this already... I should read the hole posts aging to refresh my memory before running my mouth. lol.

Edited by devanmedrow
reread previce postes
Link to comment
Share on other sites

  • 3 weeks later...

I know this hasn't gotten attention in awhile, but I want to put this out there before I give up. I can't get this plugin to do anything. (That's not entirely true - it adds on/off buttons to parts, so I know its installed.) New version of KSP, old, any kind of resources and rates, with other mods, or clean install. No resources ever get produced or consumed. If anyone has gotten something to work (preferably only with stock resources), please post the full part cfg.

Link to comment
Share on other sites

  • 10 months later...
  • 5 weeks later...
  • 1 month 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...