Jump to content

[1.8-1.9] Modular Fuel Tanks v5.13.1


taniwha

Recommended Posts

On 26.4.2016 at 0:02 AM, taniwha said:

tweakscale support should not be necessary (tweakscale should just send the right message and everything should work).

What message are you talking about? My understanding is that MFT already contains working code for MFT-TweakScale interaction using the TweakScale API. It was temporarily taken out of the release because of issues that no longer exist. And still is because noone on the MFT/realFuels side has found the time to look at the issue. 

@NathanKell : I think you did the removal. Is it still planned to eventually put this interaction code back in?

Link to comment
Share on other sites

@pellinor actually taniwha did. On the RF end, I will try to set up a similar message system to what taniwha did.

And regarding the long-suffering @Svm420's issues, yes, those still persist AFAIK, and last I checked I couldn't tell if it was our side or yours, and due to crunch didn't get a chance to look deeper.

Link to comment
Share on other sites

12 minutes ago, NathanKell said:

@pellinor actually taniwha did. On the RF end, I will try to set up a similar message system to what taniwha did.

And regarding the long-suffering @Svm420's issues, yes, those still persist AFAIK, and last I checked I couldn't tell if it was our side or yours, and due to crunch didn't get a chance to look deeper.

Wow, this was fast. Looks like I missed that, just had in memory that the interaction came as its own dll in the past, and saw that the current MFT v5.7.3 does not contain any plugins other than modularFuelTanks.dll.

Edited by pellinor
Link to comment
Share on other sites

I believe TS needs only to send an OnPartVolumeChanged event with appropriately configured data. I'm not quite certain what Procedural Parts does, but this is the code I setup to receive the event:

[KSPEvent (guiActive=false, active = true)]
void OnPartVolumeChanged (BaseEventData data)
{
    string volName = data.Get<string> ("volName");
    double newTotalVolume = data.Get<double> ("newTotalVolume") * tankVolumeConversion;
    if (volName == "Tankage") {
        ChangeTotalVolume (newTotalVolume);
    }
}

 

And this is one that MFT sends:

public void RaiseResourceInitialChanged(PartResource resource, double amount)
{
    var data = new BaseEventData (BaseEventData.Sender.USER);
    data.Set<PartResource> ("resource", resource);
    data.Set<double> ("amount", amount);
    part.SendEvent ("OnResourceInitialChanged", data, );
}

 

Link to comment
Share on other sites

Are all the stock mk2 and mk3 tanks and adapters compatible? Would this work with procedural fuel tanks? Does it work with all the resources in the community resource pack? For example could I use it to put whatever nuke fuel in procedural tanks (or even resources in procedural tanks too) and use mk2 and mk3 tanks to transport different resources to and from a USI base?

Thanks

Link to comment
Share on other sites

On 1.5.2016 at 11:32 PM, taniwha said:

I believe TS needs only to send an OnPartVolumeChanged event with appropriately configured data. I'm not quite certain what Procedural Parts does, but this is the code I setup to receive the event:

And this is one that MFT sends:

Seems I missed that post, sorry for the late reply. If I understand that right, these messages are a stock system that works on arbitrary event names and just looks for a corresponding kspEvent on each module.

So the message would be "please multiply volume by a factor of X", how would I send that? Is the total volume a field of the part something that comes from MFT?

Link to comment
Share on other sites

pellinor: Correct, this is a stock system.

However, the message tells MFT the total volume available, not a scale factor. I imagine what you could do is grab the totalVolume from the prefab's MFT module (via reflection to avoid linking issues), multiply by your scaling, then pass that to OnPartVolumeChanged.

Link to comment
Share on other sites

 

10 hours ago, taniwha said:

pellinor: Correct, this is a stock system.

However, the message tells MFT the total volume available, not a scale factor. I imagine what you could do is grab the totalVolume from the prefab's MFT module (via reflection to avoid linking issues), multiply by your scaling, then pass that to OnPartVolumeChanged.

I'm now sending this message and it seems to work (TweakScale dev version). Had to to divide the volume by 1000 since those two 'totalVolume' numbers seem to use different units.

As I understand this will currently support only MFT. And for RealFuels @NathanKell plans to hook into the same message, so the TweakScale part is fine now?

Link to comment
Share on other sites

29 minutes ago, NathanKell said:

That's true for RF tanks. RF engines will need their own work.

Maybe we can agree on some "OnPartScaleChanged" or "OnPartRescaled" message that can be reused for other modules.

Link to comment
Share on other sites

I'm getting some odd behavior. The only tanks that i have the option of changing are from the Talisar parts pack you updated. For those it works just fine, for everything else it doesn't. Seemed really strange considering you'd think if i broke something it wouldn't work at all. Any suggestions for where i can start looking?

Link to comment
Share on other sites

12 minutes ago, captinjoehenry said:

Ok this mod does not work with size changing fuel tanks.  No matter how you scale the fuel tanks it always holds the exact same amount of fuel and this issue extends to procedule fuel tanks as well.

You need to update tweakscale. The latest version corrects this issue. 

Link to comment
Share on other sites

@taniwha with the latest TweakScale and MFT I found the problem that scaling one tank sets the resource amounts of other tanks. I took two identical tanks, scaled one, and the MFT volume and resource amounts of both tanks changed. So the volume change message seems to travel from part to another. This is what I do to send the message, is that correct? My understanding is that the code should create an event that only affects the part my module is on.

                if (_prefabPart.Modules.Contains("ModuleFuelTanks"))
                {
                    var m = _prefabPart.Modules["ModuleFuelTanks"];
                    FieldInfo fieldInfo = m.GetType().GetField("totalVolume", BindingFlags.Public | BindingFlags.Instance);
                    if (fieldInfo != null)
                    {
                        double oldVol = (double)fieldInfo.GetValue(m) * 0.001d;
                        var data = new BaseEventData(BaseEventData.Sender.USER);
                        data.Set<string>("volName", "Tankage");
                        data.Set<double>("newTotalVolume", oldVol * ScalingFactor.absolute.cubic);
                        part.SendEvent("OnPartVolumeChanged", data);
                    }
                    else Tools.LogWf("MFT interaction failed (fieldinfo=null)");
                }

 

Link to comment
Share on other sites

12 hours ago, taniwha said:

You're not limiting the message to the one part. Add a 0 parameter to the call (limits the recursion depth):


part.SendEvent("OnPartVolumeChanged", data, 0);

Ah, so this is what the extra comma in your quote was coming from! Thanks a lot.

Edited by pellinor
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...