B9PartSwitch
B9PartSwitch copied to clipboard
Implement module specifics for module switching
Going to avoid adding too much before it's actually requested, but good news is that @gotmachine has already worked through a lot of it.
Code here:
https://github.com/blowfishpro/B9PartSwitch/pull/100/files#diff-85f6c7d9510a2347ee6aab7d5dc7f209R206-R339
Some documentation here:
https://github.com/blowfishpro/B9PartSwitch/pull/100#issuecomment-522259480
Changing an engine's fuel type by swapping out PROPELLANT nodes apparently doesn't send the event that ModuleEngineConfigs would send on making a similar change. Without that event, ModuleFuelTanks tanks on the same ship don't update their "fill remaining space with this engine's fuel mixture" button.
Show me the code that does it in ModuleEngineConfigs
https://github.com/NathanKell/ModularFuelSystem/blob/master/Source/Engines/ModuleEngineConfigs.cs#L855
I have a cockpit that switch from open to closed, and only the closed one can have life support and have a hatch door animated with FSanimateGeneric. So, will this part switch handle all that accordingly? Here the code! `//Cockpit Switch Type One (closed) to Open
@PART[O_cockpit]:NEEDS[B9PartSwitch] { MODULE { name = ModuleB9PartSwitch moduleID = cockpit_type switcherDescription = Cockpit Type affectDragCubes = false affectFARVoxels = false SUBTYPE { name = Cockpit_closed transform = cockpit_one
//Animation
MODULE
{
name = FSanimateGeneric
animationName = hatch_cockpit
animSpeed = 1
startEventGUIName = Open Hatch Doors
endEventGUIName = Close Hatch Doors
toggleActionName = Toggle Hatch Doors
startDeployed = False
availableInEVA = True
availableInVessel = True
EVArange = 5
playAnimationOnEditorSpawn = False
fullyRetractedEffect = closed_hatch
fullyDeployedEffect =
startDeployEffect = open_hatch
startRetractEffect = close_hatch
layer = 0
moduleID = 0
}
//Effects
EFFECTS
{
open_hatch
{
AUDIO
{
channel = Ship
clip = Omicron/Sounds/hatch_open
volume = 0.0 0.0
volume = 1.0 1.0
pitch = 0.0 0.5
pitch = 1.0 1.0
loop = false
}
}
close_hatch
{
AUDIO
{
channel = Ship
clip = Omicron/Sounds/hatch_close
volume = 0.0 0.0
volume = 1.0 1.0
pitch = 0.0 0.5
pitch = 1.0 1.0
loop = false
}
}
closed_hatch
{
AUDIO
{
channel = Ship
clip = Omicron/Sounds/hatch_closed
volume = 0.0 0.0
volume = 1.0 2.0
pitch = 0.0 0.5
pitch = 1.0 1.0
loop = false
}
}
}
@NEEDS[TacLifeSupport]
{
//RESOURCES
@RESOURCE[ElectricCharge]
{
@amount = 100
@amount *= 2
@amount *= 2.5
@amount += 150
@amount += #$maxAmount$
@maxAmount = #$amount$
}
RESOURCE
{
name = Food
amount = 1.097
maxAmount = 1.097
@amount *= 2
@amount *= 2.5
@maxAmount = #$amount$
}
RESOURCE
{
name = Water
amount = 0.725
maxAmount = 0.725
@amount *= 2
@amount *= 2.5
@maxAmount = #$amount$
}
RESOURCE
{
name = Oxygen
amount = 111.038
maxAmount = 111.038
@amount *= 2
@amount *= 2.5
@maxAmount = #$amount$
}
RESOURCE
{
name = CarbonDioxide
amount = 0
maxAmount = 95.913
@maxAmount *= 2
@maxAmount *= 2.5
}
RESOURCE
{
name = Waste
amount = 0
maxAmount = 0.1
@maxAmount *= 2
@maxAmount *= 2.5
}
RESOURCE
{
name = WasteWater
amount = 0
maxAmount = 0.924
@maxAmount *= 2
@maxAmount *= 2.5
}
//MODULES
MODULE
{
name = LifeSupportModule
}
MODULE
{
name = ModuleTestSubject
// nowhere: 0, srf: 1, ocean: 2, atmo: 4, space: 8
environments = 15
useStaging = False
useEvent = True
}
}
}
SUBTYPE
{
name = Cockpit_open
transform = cockpit_open
}
}
}`
The best way to handle FSanimateGeneric is probably to create the module outside of your B9PartSwitch, then have B9PartSwitch set the module inactive on the open-cockpit subtype:
SUBTYPE {
name = Cockpit_open
transform = cockpit_open
MODULE {
IDENTIFIER {
name = FSanimateGeneric
}
moduleActive = False
}
}
RESOURCE nodes inside a subtype don't work the same as RESOURCE nodes directly on the part; see https://github.com/blowfishpro/B9PartSwitch/wiki/Tank-Definitions for how they actually work.
@rvalle7 few things
- Check your formatting - the code tags got messed up. Good case for preview/proofreading - you should still be able to edit the comment still
-
EFFECTS
is not recognized on a subtype. - As @bfrobin446 said, while
RESOURCE
s can be defined directly on the subtype, your definitions aren't correct.- This seems like abuse of the feature anyway. There should be a tank type you can use. Defining resources directly on the subtype should be reserved for weird one-off cases.
- Your
@NEEDS[TacLifeSupport] { }
node is not going to work. ModuleManager doesn't work like that. - B9PartSwitch doesn't actually add modules, it can only modify and (sorta) disable them.
- The way to "disable" a module (for the most part it only hides the UI is as such:
MODULE { IDENTIFIER { name = whatever // any other fields used to uniquely identify the module } moduleActive = false }
- The way to load new data into a module:
MODULE { IDENTIFIER { name = whatever // any other fields used to uniquely identify the module } DATA { // new data to be loaded into the module } }
- The way to "disable" a module (for the most part it only hides the UI is as such:
Yes, the resources i already figure out and put it on a tankswitch and it worked. I'll do what you described here for the FSanimateGeneric.
Chears commanders. Good Karma for you both!
Sent from iCloud Rafael Valle
On April 20, 2020 at 3:33 PM, Joseph Wong [email protected] wrote:
So, i tried and it worked for all other things inside, but vanish with animation in both cases. And i can't make it start in closed mode, it always go to open mode. I tried defaulSuptypePriority , i tried inverting the description order in ModuleB9PartSwitch. I'm using 1.9.1.
MODULE
{
name = ModuleB9PartSwitch
moduleID = cockpit_type
switcherDescription = Cockpit Type
affectDragCubes = false
affectFARVoxels = false
baseVolume = 1048
SUBTYPE
{
name = Cockpit_closed
transform = cockpit_one
tankType = Cockpit_closed
MODULE
{
IDENTIFIER
{
name = FSanimateGeneric
}
moduleActive = true
}
}
SUBTYPE
{
name = Cockpit_open
transform = cockpit_open
tankType = Cockpit_open
MODULE
{
IDENTIFIER
{
name = FSanimateGeneric
}
moduleActive = false
}
}
}
Your formatting is still off
This is right and it works: @PART[O_egg_crew_three]:NEEDS[B9PartSwitch]
But this don't work, and syntax is what you all described here, exactly. So, i don't think this MODULE implementation on your ModuleB9PartSwitch is ready, at least for FSanimateGeneric and ModuleGenericAnimation.
MODULE
{
IDENTIFIER
{
name = FSanimateGeneric
}
moduleActive = false
}
The module switching has been tested with almost nothing and many modules will respond differently. That's the purpose of this issue. I make no guarantees about what it will work initially but I'm willing to work with modders to get things working, particularly with stock modules.
But if you come to me with a bunch of bad syntax I'm going to make you fix that first.
I can be tester for the ModuleGenericAnimate if you need some one. I do some light stuff in code too, i'm starting with Omicron Cockpit panel on the ship (not IVA, soon i will put the code here in my Github), already did the navball, going to speed, altimeter etc. So i do know some. But little. My purpose in all the messages is to point out what i did and what was your module response. Let me know how can i help more. Cheers! For the bad syntax, for sure, but the last one wasn't. This editor was. It fuck the syntax when i put that @part. for itself.