Jump to content

Problems with ModuleManager and FSfuelSwitch


cy-one

Recommended Posts

this is a cross-post from the MM-thread, as I hope to find a bit more help here (as it's a problem that might well be based on my understanding of FSfuelSwitch, I'm really not sure... So limiting my search for help to the MM-thread might be bad.

Okay, I'm having a few (well, actually one) Problems with variables, I think.

I'm trying to write a small patch that adds FSfuelSwitch to stock tanks.

@PART[fuelTank3-2]:NEEDS[Firespitter]:HAS[!MODULE[FSfuelSwitch]] {
// original values
resLF = #$/RESOURCE[LiquidFuel]/amount$
maxLF = #$/RESOURCE[LiquidFuel]/maxAmount$
resO = #$/RESOURCE[Oxidizer]/amount$
maxO = #$/RESOURCE[Oxidizer]/maxAmount$

// combined LF+O values
resComb = resLF
resComb += resO
maxComb = maxLF
maxComb += maxO

// create FSfuelSwitch
MODULE {
name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer; LiquidFuel; Oxidizer
//resourceAmounts = maxLF,maxO; maxComb; maxComb
//initialResourceAmounts = resLF,resO; resComb; resComb
resourceAmounts = 100,100; 200; 200
initialResourceAmounts = 100,100; 200; 200
basePartMass = 4
tankMass = 0; 0; 0
tankCost = 0; 0; 0
displayCurrentTankCost = false
hasGui = true
availableInFlight = true
availableInEditor = true
showInfo = true
}

// delete temp variables
!resLF = null
!maxLF = null
!resO = null
!maxO = null
!resComb = null
!maxComb = null

// delete original resources
!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
}

I used the example from page 142, but it doesn't quite work.

You see, I commented my initial code (resourceAmounts & initialAmounts with variables) out, as it didn't work. The FSfuelSwitch-MODULE itself works fine, as the dummy-code with 100 and 200 as values worked as expected.

Where did I went ...... and ....ed things up? :(

Edit:

Yeah, for one tank this is overengineered, but one might assume I want to extend the functionality to more than just the jumbo-tank ;) also more resources.

Edit: I'd also appreciate any comment on the code, I'm not that experienced and just winged the whole @PART:NEEDS:HAS-thing, dunno if that's actually done well :D

Edit: In case it helps, fsFuelSwitch did show the expected GUI in the Tweakables (also showed the available resources in the tooltip)when I used the variables in the code, but it didn't show any actual resources in the Tweakables.

Edit: Okay, it's getting weirder and weirder...

	resComb = #$resLF$
resComb += #$resO$
maxComb = #$maxLF$
maxComb += #$maxO$

// create FSfuelSwitch
MODULE {
name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer; LiquidFuel; Oxidizer
resourceAmounts = #$maxLF$,#$maxO$; #$maxComb$; #$maxComb$
initialResourceAmounts = #$resLF$,#$resO$; #$resComb$; #$resComb$

Ingame, FSfuelSwitch is now displaying

"LiquidFuel 100/100" (no Oxidizer),

"LiquidFuel 75/75",

"Oxidizer 200/200"

I even deleted (not only out-commented) the "dummy-lines" with 100,100;200;200, just to make sure... So no Idea how those numbers end up in-game... Halp! :(

Edited by cy-one
Link to comment
Share on other sites

  • 2 weeks later...

Read the ModuleManager manual about variables. This code works (I've made it myself):


//CC-BY-SA

//This patch adds FSfuelSwitch to bipropellant tanks (LiquidFuel+Oxidizer).

@PART
[*]:HAS[@RESOURCE[Oxidizer]] //change to LiquidFuel if you want to have FuelSwitch on jet fuel tanks as well
{
lfifplusox = #$/RESOURCE[LiquidFuel]/amount$ //liquid fuel if plus oxidizer
oxifpluslf = #$/RESOURCE[Oxidizer]/amount$ //oxidizer if plus liquid fuel
lforox = #$/lfifplusox$ //liquid fuel or oxidizer
@lforox += #$/oxifpluslf$


!RESOURCE[LiquidFuel] {}
!RESOURCE[Oxidizer] {}
MODULE
{
name = FSfuelSwitch
resourceNames = LiquidFuel,Oxidizer;LiquidFuel;Oxidizer
resourceAmounts = #$/lfifplusox$ , $/oxifpluslf$ ; $/lforox$ ; $/lforox$
basePartMass = #$/mass$
//tankMass = 0;0;0
//tankCost =0;0;0
displayCurrentTankCost = false
hasGUI = true
availableInFlight = false
availableInEditor = true
showInfo = true
}


I'll make a thread for it soon.

Oh, I see what did you mess up. You need only one # before using variables. You place # before using every variable. FSfuelSwitcher gets #75 instead of just 75. If you look deeply into logs you'll find something like this:

[LOG 17:32:30.268] FSfuelSwitch: error parsing resource amount 0/1: ' #100 ': '#55'

Edited by micha030201
Link to comment
Share on other sites

  • 2 years later...

Sorry to necro this but I need a bit of help:

MODULE
	{
		name = FStextureSwitch2
		nextButtonText = Next resource
		prevButtonText = Previous resource
		statusText = Current resource
		switchableInFlight = true
		repaintableEVA = false
		textureRootFolder = MacLuky/SmallTAC/
		textureNames = hexempty;hexfood;hexwater;hexlifesupport;hexoxygen;hexwaste
		objectNames = Untagged
		textureDisplayNames = Empty;Food;Water;LifeSupport;Oxygen;Waste
		useFuelSwitchModule = true
		fuelTankSetups = 0;1;2;3;4;5
	}

I am trying to clean up the TAC parts that clutter my part list. I can't get them to switch textures properly. Looking at the .mu file I think the mesh is named Untagged or HexCan. I tried both, but am still puzzling. Can anyone give me a pointer? Fuel switches properly, currently figureing out how to hide the parts.

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