Jump to content

[0.24.2] Generic Resource Converter v1.22[Updated 8/5/14]


Recommended Posts

So, I remade the craft you were using in the video (and added canOverflow = true to the part.cfg), except I also included a battery to increase the max amount of available electric charge. It works perfectly in this case.

The issue occurs because, at timewarps that high, the converter is trying to use more of the resource per cycle than the vessel can hold, so it thinks it's underflowing and is limiting the efficiency based on that. Basically, every cycle it's reducing the electric charge to zero (and running out), then filling it all back up at the end. I'm not sure there is a way around this.... Although in reality it would be producing electricity simultaneously, in the code it's very difficult to do that. :\

I did however fix the small error that occurred with the electric charge going crazy high during timewarp. I'd forgot to make something an absolute value in the code, so it was evaluating a conditional incorrectly. :)

Here's a video of my test:

Link to comment
Share on other sites

To calculate how much space you'll need:

* the part consumes 0.5 charge per second

* the converter updates every 0.02 seconds (game time) at 1x, which is the rate Unity updates its physics by default

* at 100,000x, it updates every 2000 seconds (game time)

0.5 * 2000 = 1000 electric charge

Link to comment
Share on other sites

To calculate how much space you'll need:

* the part consumes 0.5 charge per second

* the converter updates every 0.02 seconds (game time) at 1x, which is the rate Unity updates its physics by default

* at 100,000x, it updates every 2000 seconds (game time)

0.5 * 2000 = 1000 electric charge

This is why before it was only operating at 5000x:

0.02 * 5000 = 100

100 * 0.5 = 50 (the max amount of charge on your craft)

Link to comment
Share on other sites

I'm not sure there is a way around this....

I could split the Convert() method up into a bunch of smaller ones at high timewarp, but that would probably get pretty computationally expensive (it'd have to execute 20 times per physics cycle instead of the 1 at the 0.5 rate with a max charge of 50).

Edited by okbillybunnyface
Link to comment
Share on other sites

Ah! The electricity input doesn't have to be there. That was to fix the strange issue with the earlier version requiring flow types for the input. I'd forgotten it was in there *face palm*

Took it out and it runs perfectly!

Power it a requirement for the other generators but that'll work fine because I expect it to be a required input *double face palm*

So I'll update my downloads tonight. Thanks for taking care of this, sorry for running you down the wrong path with the power thing.

Link to comment
Share on other sites

Ah! The electricity input doesn't have to be there. That was to fix the strange issue with the earlier version requiring flow types for the input. I'd forgotten it was in there *face palm*

Took it out and it runs perfectly!

Power it a requirement for the other generators but that'll work fine because I expect it to be a required input *double face palm*

So I'll update my downloads tonight. Thanks for taking care of this, sorry for running you down the wrong path with the power thing.

No worries! It was something I was more or less already aware of. I should note, however, that you'll encounter the same problem with any other input resources. It's only because electric charge is the one most commonly being constantly refilled that it appears as a bug. Anything that isn't being refilled will just run out, lol.

It'd be nice if I could pull directly from incoming resources prior to dipping into the vessel's stockpile. That'd circumvent the issue entirely.

Edited by okbillybunnyface
Link to comment
Share on other sites

Why not add a check if (totalCraftECConsumption < EC generated) then {// I don't care} else {// Underflowing could happen} ?

By the way, does the converter use units or mass for input / output ?

Edited by invultri
Link to comment
Share on other sites

Why not add a check if (totalCraftECConsumption < EC generated) then {// I don't care} else {// Underflowing could happen} ?

By the way, does the converter use units or mass for input / output ?

That would be the best way to do it, but I'm not sure how to get those values. I haven't been able to find any internal vars that keep track of incoming/outgoing resources.

The rate specifies units/second.

Link to comment
Share on other sites

  • 1 month later...

Not sure if this is the best place to report it, but I'm getting this in my logs from ResourceConverter:


PartLoader: Compiling Part 'US_TAC/Parts/US_Wedge_P30_Sabatier/part/US_Wedge_Sabatier'

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

NullReferenceException: Object reference not set to an instance of an object
at Planetarium.GetUniversalTime () [0x00000] in <filename unknown>:0

at ModuleResourceConverter..ctor () [0x00000] in <filename unknown>:0
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type)
Part:AddModule(String)
Part:AddModule(ConfigNode)
PartLoader:ParsePart(UrlConfig, ConfigNode)

:MoveNext()

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object
at Planetarium.GetUniversalTime () [0x00000] in <filename unknown>:0

at ModuleResourceConverter..ctor () [0x00000] in <filename unknown>:0
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Instantiate(Object)
PartLoader:CreatePartIcon(GameObject, Single&)
PartLoader:ParsePart(UrlConfig, ConfigNode)

:MoveNext()

(Filename: Line: -1)

PartLoader: Compiling Part 'US_TAC/Parts/US_Wedge_P40_WRS/part/US_Wedge_WRS'

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

NullReferenceException: Object reference not set to an instance of an object
at Planetarium.GetUniversalTime () [0x00000] in <filename unknown>:0

at ModuleResourceConverter..ctor () [0x00000] in <filename unknown>:0
UnityEngine.GameObject:Internal_AddComponentWithType(Type)
UnityEngine.GameObject:AddComponent(Type)
Part:AddModule(String)
Part:AddModule(ConfigNode)
PartLoader:ParsePart(UrlConfig, ConfigNode)

:MoveNext()

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object
at Planetarium.GetUniversalTime () [0x00000] in <filename unknown>:0

at ModuleResourceConverter..ctor () [0x00000] in <filename unknown>:0
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Instantiate(Object)
PartLoader:CreatePartIcon(GameObject, Single&)
PartLoader:ParsePart(UrlConfig, ConfigNode)

:MoveNext()

(Filename: Line: -1)

PartLoader: Compiling Part 'US_TAC/Parts/US_Wedge_R120_Carbon/part/US_Wedge_Carbon'

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

Link to comment
Share on other sites

  • 2 weeks later...
Hey,

I've added the ResourceConverter file to my GameData folder, but no part seems to be added. Should there be a part added, or am I just missing something?

It's just a Plugin there is no part, Universal Storage use's it just alittle different then ModuleGenerator but you can write your owen too.

Link to comment
Share on other sites

I started using the universal storage parts recently and saw the fuel cell and electron parts.... (COOL now I can have a large amount of electrical storage, with efficiency and speed limitations, but still much better than a huge number of batteries)

..... but when I started testing my new comm satellites (for use with remotetech2 eclipses are annoying) I had one huge problem....... I could not activate both the fuel cell and electron at the same time because they do not care about the level of electric charge...... they just drain energy from the system (since the electron takes more energy to split water than the fuel cell gets back....)

So I took a look at the source code and decided to break out my programming hat (haven't done much work in C, mostly I have dabbled in a basic language and some assembly for PIC micros)

I added two new options (in the same style as your "can overflow") that allowed the fuel cell and the electron to work in tandem.

Pause if vessel is near full

Pause if vessel is not near full

The first one compares the first listed output resource and skips a conversion cycle if this resource is more than 89% of vessel capacity

The second one compares the first listed input resource and skips a conversion cycle if this resource is less than 91% of vessel capacity

I also added two new display options to indicate this paused state in the part's right click gui

If you want me to post my additions I will happily do so, although at least one part of my addition; the compare of the first listed resource, is very clumsy in that is uses your "foreach" loop and forcibly exits at the end of the first iteration every time instead of a more simple call of the single item, this is mostly due to my inexperience with C but also due to my own lazyness ;}

Link to comment
Share on other sites

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