Jump to content

What do "istg" and "dstg" mean in .craft files?


Ezriilc

Recommended Posts

I'm trying to write a .craft file parser that can calculate TWR for each stage, and other stuff, but I can't seem to figure out what "istg" and "dstg" mean with any confidence. I've read everything I can find about it here, and even necro'd another thread, but I figured it would get more attention with a more specific Title.

Can anyone help me to understand "istg" and "dstg" in .craft files? Thanks in advance!

Link to comment
Share on other sites

I've built a simple ship with stages, to learn this. The ship has 6 stages as seen in the VAB, but there are 8+ different istg/dstg values... :confused: and that makes my head hurt.

ship = Stages Demo
version = 0.23.0
description = A simple stack, for practice.
type = VAB
PART
{
part = probeCoreHex_4294616496
partName = Part
pos = -2.060127E-06,18.48516,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 0
dstg = 0
sidx = -1
sqor = -1
attm = 0
link = miniFuelTank_4294616460
link = mumech.MJ2.AR202_4294594312
attN = bottom,miniFuelTank_4294616460
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleCommand
isEnabled = True
controlSrcStatusText =
EVENTS
{
MakeReference
{
active = True
guiActive = True
guiIcon = Control From Here
guiName = Control From Here
category = Control From Here
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
RenameVessel
{
active = True
guiActive = True
guiIcon = Rename Vessel
guiName = Rename Vessel
category = Rename Vessel
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
}
}
MODULE
{
name = ModuleReactionWheel
isEnabled = True
stateString = Active
WheelState = Active
EVENTS
{
OnToggle
{
active = True
guiActive = True
guiIcon = Toggle Torque
guiName = Toggle Torque
category = Toggle Torque
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
Activate
{
actionGroup = None
}
Deactivate
{
actionGroup = None
}
Toggle
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleSAS
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleTripLogger
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
Surfaced
{
}
Flew
{
}
FlewBy
{
}
Orbited
{
}
SubOrbited
{
}
}
RESOURCE
{
name = ElectricCharge
amount = 10
maxAmount = 10
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = miniFuelTank_4294616460
partName = Part
pos = -2.060127E-06,18.12339,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 0
dstg = 0
sidx = -1
sqor = -1
attm = 0
link = liquidEngineMini_4294616432
attN = top,probeCoreHex_4294616496
attN = bottom,liquidEngineMini_4294616432
EVENTS
{
}
ACTIONS
{
}
RESOURCE
{
name = LiquidFuel
amount = 5.735
maxAmount = 5.735
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
RESOURCE
{
name = Oxidizer
amount = 7
maxAmount = 7
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = liquidEngineMini_4294616432
partName = Part
pos = -2.060127E-06,17.94912,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 0
dstg = 0
sidx = 0
sqor = 0
attm = 0
link = stackDecouplerMini_4294616362
attN = top,miniFuelTank_4294616460
attN = bottom,stackDecouplerMini_4294616362
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleJettison
isEnabled = True
EVENTS
{
Jettison
{
active = False
guiActive = True
guiIcon = Jettison
guiName = Jettison
category = Jettison
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
JettisonAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGimbal
isEnabled = True
gimbalLock = False
EVENTS
{
LockGimbal
{
active = True
guiActive = True
guiActiveEditor = True
guiIcon = Lock Gimbal
guiName = Lock Gimbal
category = Lock Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
FreeGimbal
{
active = False
guiActive = True
guiActiveEditor = True
guiIcon = Free Gimbal
guiName = Free Gimbal
category = Free Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
}
}
}
PART
{
part = stackDecouplerMini_4294616362
partName = Part
pos = -2.060127E-06,17.49821,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 0
dstg = 1
sidx = 1
sqor = 0
attm = 0
link = fuelTankSmallFlat_4294616336
attN = bottom,fuelTankSmallFlat_4294616336
attN = top,liquidEngineMini_4294616432
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleDecouple
isEnabled = True
isDecoupled = False
EVENTS
{
Decouple
{
active = True
guiActive = True
guiIcon = Decouple
guiName = Decouple
category = Decouple
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
DecoupleAction
{
actionGroup = None
}
}
}
}
PART
{
part = fuelTankSmallFlat_4294616336
partName = Part
pos = -2.060127E-06,17.1098,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 2
dstg = 2
sidx = -1
sqor = -1
attm = 0
link = liquidEngine3_4294616306
attN = top,stackDecouplerMini_4294616362
attN = bottom,liquidEngine3_4294616306
EVENTS
{
}
ACTIONS
{
}
RESOURCE
{
name = LiquidFuel
amount = 45
maxAmount = 45
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
RESOURCE
{
name = Oxidizer
amount = 55
maxAmount = 55
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = liquidEngine3_4294616306
partName = Part
pos = -2.060127E-06,16.52667,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 1
dstg = 2
sidx = 0
sqor = 1
attm = 0
link = stackDecoupler_4294616220
attN = top,fuelTankSmallFlat_4294616336
attN = bottom,stackDecoupler_4294616220
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGimbal
isEnabled = True
gimbalLock = False
EVENTS
{
LockGimbal
{
active = True
guiActive = True
guiActiveEditor = True
guiIcon = Lock Gimbal
guiName = Lock Gimbal
category = Lock Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
FreeGimbal
{
active = False
guiActive = True
guiActiveEditor = True
guiIcon = Free Gimbal
guiName = Free Gimbal
category = Free Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleAnimateHeat
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleJettison
isEnabled = True
EVENTS
{
Jettison
{
active = False
guiActive = True
guiIcon = Jettison
guiName = Jettison
category = Jettison
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
JettisonAction
{
actionGroup = None
}
}
}
}
PART
{
part = stackDecoupler_4294616220
partName = Part
pos = -2.060127E-06,15.98881,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 1
dstg = 3
sidx = 1
sqor = 1
attm = 0
link = fuelTank4-2_4294616184
attN = bottom,fuelTank4-2_4294616184
attN = top,liquidEngine3_4294616306
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleDecouple
isEnabled = True
isDecoupled = False
EVENTS
{
Decouple
{
active = True
guiActive = True
guiIcon = Decouple
guiName = Decouple
category = Decouple
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
DecoupleAction
{
actionGroup = None
}
}
}
}
PART
{
part = fuelTank4-2_4294616184
partName = Part
pos = -2.060127E-06,15.38706,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 4
dstg = 4
sidx = -1
sqor = -1
attm = 0
link = liquidEngine2-2_4294571248
attN = top,stackDecoupler_4294616220
attN = bottom,liquidEngine2-2_4294571248
EVENTS
{
}
ACTIONS
{
}
RESOURCE
{
name = LiquidFuel
amount = 360
maxAmount = 360
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
RESOURCE
{
name = Oxidizer
amount = 440
maxAmount = 440
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = mumech.MJ2.AR202_4294594312
partName = Part
pos = -2.08908E-06,18.67266,-0.3311886
rot = -3.090862E-08,0.7071068,-3.090862E-08,-0.7071068
attRot = 0.7071067,0,0,0.7071067
mir = 1,1,1
istg = 0
dstg = 0
sidx = -1
sqor = -1
attm = 1
srfN = srfAttach,probeCoreHex_4294616496
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleCommand
isEnabled = True
controlSrcStatusText =
EVENTS
{
MakeReference
{
active = True
guiActive = True
guiIcon = Control From Here
guiName = Control From Here
category = Control From Here
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
RenameVessel
{
active = True
guiActive = True
guiIcon = Rename Vessel
guiName = Rename Vessel
category = Rename Vessel
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
}
}
MODULE
{
name = MechJebCore
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
MechJebLocalSettings
{
MechJebModuleJoke
{
unlockParts =
unlockTechs =
}
MechJebModuleMenu
{
unlockParts =
unlockTechs =
}
MechJebModuleCustomWindowEditor
{
unlockParts =
unlockTechs = flightControl
}
MechJebModuleDockingAutopilot
{
forceRol = False
unlockParts =
unlockTechs =
rol
{
val = 0
_text = 0
}
}
MechJebModuleNodeExecutor
{
unlockParts =
unlockTechs =
}
MechJebModuleNodeEditor
{
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleAscentPathEditor
{
unlockParts =
unlockTechs =
}
MechJebModuleInfoItems
{
unlockParts =
unlockTechs =
}
MechJebModuleJokeObscurePanel
{
unlockParts =
unlockTechs =
}
MechJebModuleAttitudeAdjustment
{
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleDockingGuidance
{
unlockParts =
unlockTechs = advUnmanned
}
MechJebModuleCustomInfoWindow
{
}
MechJebModuleCustomInfoWindow
{
}
MechJebModuleCustomInfoWindow
{
}
MechJebModuleCustomInfoWindow
{
}
MechJebModuleLandingAutopilot
{
deployGears = True
deployChutes = True
unlockParts =
unlockTechs =
touchdownSpeed
{
val = 0.5
_text = 0.5
}
limitGearsStage
{
val = 0
_text = 0
}
limitChutesStage
{
val = 0
_text = 0
}
}
MechJebModuleManeuverPlanner
{
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleRCSBalancerWindow
{
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleLandingPredictions
{
unlockParts =
unlockTechs =
}
MechJebModuleLandingGuidance
{
unlockParts =
unlockTechs = unmannedTech
}
MechJebModuleAscentGuidance
{
unlockParts =
unlockTechs = unmannedTech
}
MechJebModuleRoverController
{
unlockParts =
unlockTechs =
heading
{
val = 0
_text = 0
}
speed
{
val = 10
_text = 10
}
}
MechJebModuleRendezvousAutopilotWindow
{
unlockParts =
unlockTechs = advUnmanned
}
MechJebModuleRoverWindow
{
unlockParts =
unlockTechs = fieldScience
}
MechJebModuleRoverWaypointWindow
{
unlockParts =
unlockTechs =
}
MechJebModuleRendezvousGuidance
{
unlockParts =
unlockTechs = advUnmanned
}
MechJebModuleSettings
{
unlockParts =
unlockTechs =
}
MechJebModuleRoverWaypointHelpWindow
{
unlockParts =
unlockTechs =
}
MechJebModuleSmartASS
{
mode = ORBITAL
target = OFF
advReference = INERTIAL
advDirection = FORWARD
forceRol = False
unlockParts =
unlockTechs = flightControl
srfHdg
{
val = 90
_text = 90
}
srfPit
{
val = 90
_text = 90
}
srfRol
{
val = 0
_text = 0
}
rol
{
val = 0
_text = 0
}
}
MechJebModuleSpaceplaneAutopilot
{
unlockParts =
unlockTechs =
}
MechJebModuleThrustWindow
{
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleTranslatron
{
trans_spd = 0
unlockParts =
unlockTechs = advFlightControl
}
MechJebModuleRendezvousAutopilot
{
unlockParts =
unlockTechs =
}
MechJebModuleAscentAutopilot
{
unlockParts =
unlockTechs =
}
MechJebModuleTargetController
{
unlockParts =
unlockTechs =
}
ModExtensionDemo
{
unlockParts =
unlockTechs =
}
MechJebModuleSpaceplaneGuidance
{
unlockParts =
unlockTechs = unmannedTech
}
MechJebModuleStageStats
{
unlockParts =
unlockTechs =
}
MechJebModuleWarpHelper
{
unlockParts =
unlockTechs = advFlightControl
phaseAngle
{
val = 0
_text = 0
}
}
MechJebModuleWarpController
{
unlockParts =
unlockTechs =
}
MechJebModuleThrustController
{
limitThrottle = False
unlockParts =
unlockTechs =
maxThrottle
{
val = 1
_text = 100
}
}
MechJebModuleRCSController
{
unlockParts =
unlockTechs =
}
MechJebModuleRCSBalancer
{
unlockParts =
unlockTechs =
}
MechJebModuleAttitudeController
{
Tf = 0.1
unlockParts =
unlockTechs =
}
MechJebModuleStagingController
{
unlockParts =
unlockTechs =
}
MechJebModuleFlightRecorder
{
markUT = 0
deltaVExpended = 0
dragLosses = 0
gravityLosses = 0
steeringLosses = 0
markLatitude = 0
markLongitude = 0
markAltitude = 0
markBodyIndex = 1
maxDragGees = 0
unlockParts =
unlockTechs =
}
}
}
MODULE
{
name = MechJebAR202
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleTripLogger
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
Surfaced
{
}
Flew
{
}
FlewBy
{
}
Orbited
{
}
SubOrbited
{
}
}
RESOURCE
{
name = ElectricCharge
amount = 5
maxAmount = 5
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = liquidEngine2-2_4294571248
partName = Part
pos = -2.060127E-06,14.19137,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 2
dstg = 4
sidx = 0
sqor = 2
attm = 0
link = decoupler1-2_4294559564
attN = top,fuelTank4-2_4294616184
attN = bottom,decoupler1-2_4294559564
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleJettison
isEnabled = True
EVENTS
{
Jettison
{
active = False
guiActive = True
guiIcon = Jettison
guiName = Jettison
category = Jettison
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
JettisonAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGimbal
isEnabled = True
gimbalLock = False
EVENTS
{
LockGimbal
{
active = True
guiActive = True
guiActiveEditor = True
guiIcon = Lock Gimbal
guiName = Lock Gimbal
category = Lock Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
FreeGimbal
{
active = False
guiActive = True
guiActiveEditor = True
guiIcon = Free Gimbal
guiName = Free Gimbal
category = Free Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleAnimateHeat
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleAlternator
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
RESOURCE
{
name = ElectricCharge
amount = 0
maxAmount = 0
flowState = True
isTweakable = False
hideFlow = True
flowMode = Both
}
}
PART
{
part = decoupler1-2_4294559564
partName = Part
pos = -2.060127E-06,13.00508,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 2
dstg = 5
sidx = 1
sqor = 2
attm = 0
link = fuelTank4-2_4294559174
attN = bottom,fuelTank4-2_4294559174
attN = top,liquidEngine2-2_4294571248
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleDecouple
isEnabled = True
isDecoupled = False
EVENTS
{
Decouple
{
active = True
guiActive = True
guiIcon = Decouple
guiName = Decouple
category = Decouple
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
DecoupleAction
{
actionGroup = None
}
}
}
}
PART
{
part = fuelTank4-2_4294559174
partName = Part
pos = -2.060127E-06,12.17086,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 6
dstg = 6
sidx = -1
sqor = -1
attm = 0
link = liquidEngine2-2_4294559142
attN = top,decoupler1-2_4294559564
attN = bottom,liquidEngine2-2_4294559142
EVENTS
{
}
ACTIONS
{
}
RESOURCE
{
name = LiquidFuel
amount = 360
maxAmount = 360
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
RESOURCE
{
name = Oxidizer
amount = 440
maxAmount = 440
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = liquidEngine2-2_4294559142
partName = Part
pos = -2.060127E-06,10.97517,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 3
dstg = 6
sidx = 0
sqor = 3
attm = 0
link = decoupler1-2_4294552894
attN = top,fuelTank4-2_4294559174
attN = bottom,decoupler1-2_4294552894
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleJettison
isEnabled = True
EVENTS
{
Jettison
{
active = False
guiActive = True
guiIcon = Jettison
guiName = Jettison
category = Jettison
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
JettisonAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGimbal
isEnabled = True
gimbalLock = False
EVENTS
{
LockGimbal
{
active = True
guiActive = True
guiActiveEditor = True
guiIcon = Lock Gimbal
guiName = Lock Gimbal
category = Lock Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
FreeGimbal
{
active = False
guiActive = True
guiActiveEditor = True
guiIcon = Free Gimbal
guiName = Free Gimbal
category = Free Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleAnimateHeat
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleAlternator
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
RESOURCE
{
name = ElectricCharge
amount = 0
maxAmount = 0
flowState = True
isTweakable = False
hideFlow = True
flowMode = Both
}
}
PART
{
part = decoupler1-2_4294552894
partName = Part
pos = -2.060127E-06,9.788878,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 3
dstg = 7
sidx = 1
sqor = 3
attm = 0
link = fuelTank4-2_4294552824
attN = bottom,fuelTank4-2_4294552824
attN = top,liquidEngine2-2_4294559142
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleDecouple
isEnabled = True
isDecoupled = False
EVENTS
{
Decouple
{
active = True
guiActive = True
guiIcon = Decouple
guiName = Decouple
category = Decouple
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
DecoupleAction
{
actionGroup = None
}
}
}
}
PART
{
part = fuelTank4-2_4294552824
partName = Part
pos = -2.060127E-06,8.954658,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 8
dstg = 8
sidx = -1
sqor = -1
attm = 0
link = sepMotor1_4294542100
link = sepMotor1_4294541692
link = launchClamp1_4294534672
link = launchClamp1_4294534432
link = liquidEngine2-2_4294529886
attN = top,decoupler1-2_4294552894
attN = bottom,liquidEngine2-2_4294529886
EVENTS
{
}
ACTIONS
{
}
RESOURCE
{
name = LiquidFuel
amount = 360
maxAmount = 360
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
RESOURCE
{
name = Oxidizer
amount = 440
maxAmount = 440
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = sepMotor1_4294542100
partName = Part
pos = -2.165684E-06,8.957479,-1.207428
rot = 0,1,0,-4.371139E-08
attRot = 0,0,0,1
mir = 1,1,1
istg = 4
dstg = 8
sidx = 0
sqor = 4
attm = 1
sym = sepMotor1_4294541692
srfN = srfAttach,fuelTank4-2_4294552824
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
RESOURCE
{
name = SolidFuel
amount = 8
maxAmount = 8
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = sepMotor1_4294541692
partName = Part
pos = -1.849013E-06,8.957479,1.20743
rot = 0,-8.742278E-08,0,-1
attRot = 0,0,0,1
mir = 1,1,1
istg = 4
dstg = 8
sidx = 1
sqor = 4
attm = 1
sym = sepMotor1_4294542100
srfN = srfAttach,fuelTank4-2_4294552824
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
RESOURCE
{
name = SolidFuel
amount = 8
maxAmount = 8
flowState = True
isTweakable = True
hideFlow = False
flowMode = Both
}
}
PART
{
part = launchClamp1_4294534672
partName = Strut
pos = -1.434742,7.62464,-1.43474
rot = 7.378751E-08,-0.3826834,-1.97714E-08,-0.9238796
attRot = 0,0,0,1
mir = 1,1,1
istg = 4
dstg = 8
sidx = 2
sqor = 4
attm = 1
sym = launchClamp1_4294534432
srfN = srfAttach,fuelTank4-2_4294552824
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = LaunchClamp
isEnabled = True
scaleFactor = 3.28345
height = 8.284793
towerRot = -7.378751E-08,0.3826834,1.97714E-08,-0.9238796
EVENTS
{
Release
{
active = False
guiActive = True
guiIcon = Release Clamp
guiName = Release Clamp
category = Release Clamp
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ReleaseClamp
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGenerator
isEnabled = True
generatorIsActive = False
throttle = 0
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Generator
guiName = Activate Generator
category = Activate Generator
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = True
guiActive = True
guiIcon = Shutdown Generator
guiName = Shutdown Generator
category = Shutdown Generator
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
}
}
}
PART
{
part = launchClamp1_4294534432
partName = Strut
pos = 1.434739,7.62464,1.434742
rot = -1.977141E-08,-0.9238796,-7.378751E-08,0.3826834
attRot = 0,0,0,1
mir = 1,1,1
istg = 4
dstg = 8
sidx = 3
sqor = 4
attm = 1
sym = launchClamp1_4294534672
srfN = srfAttach,fuelTank4-2_4294552824
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = LaunchClamp
isEnabled = True
scaleFactor = 3.28345
height = 8.284793
towerRot = 1.977141E-08,0.9238796,7.378751E-08,0.3826834
EVENTS
{
Release
{
active = False
guiActive = True
guiIcon = Release Clamp
guiName = Release Clamp
category = Release Clamp
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ReleaseClamp
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGenerator
isEnabled = True
generatorIsActive = False
throttle = 0
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Generator
guiName = Activate Generator
category = Activate Generator
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = True
guiActive = True
guiIcon = Shutdown Generator
guiName = Shutdown Generator
category = Shutdown Generator
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
}
}
}
PART
{
part = liquidEngine2-2_4294529886
partName = Part
pos = -2.060127E-06,7.758967,1.002243E-06
rot = 0,0,0,1
attRot = 0,0,0,1
mir = 1,1,1
istg = 5
dstg = 8
sidx = 0
sqor = 5
attm = 0
attN = top,fuelTank4-2_4294552824
EVENTS
{
}
ACTIONS
{
}
MODULE
{
name = ModuleEngines
isEnabled = True
staged = False
flameout = False
EngineIgnited = False
engineShutdown = False
currentThrottle = 0
thrustPercentage = 100
manuallyOverridden = False
thrustPercentage_UIFlight
{
controlEnabled = True
minValue = 0
maxValue = 100
stepIncrement = 0.5
}
EVENTS
{
Activate
{
active = True
guiActive = True
guiIcon = Activate Engine
guiName = Activate Engine
category = Activate Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
Shutdown
{
active = False
guiActive = True
guiIcon = Shutdown Engine
guiName = Shutdown Engine
category = Shutdown Engine
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
OnAction
{
actionGroup = None
}
ShutdownAction
{
actionGroup = None
}
ActivateAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleJettison
isEnabled = True
EVENTS
{
Jettison
{
active = False
guiActive = True
guiIcon = Jettison
guiName = Jettison
category = Jettison
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
JettisonAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleGimbal
isEnabled = True
gimbalLock = False
EVENTS
{
LockGimbal
{
active = True
guiActive = True
guiActiveEditor = True
guiIcon = Lock Gimbal
guiName = Lock Gimbal
category = Lock Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
FreeGimbal
{
active = False
guiActive = True
guiActiveEditor = True
guiIcon = Free Gimbal
guiName = Free Gimbal
category = Free Gimbal
guiActiveUnfocused = False
unfocusedRange = 2
externalToEVAOnly = True
}
}
ACTIONS
{
ToggleAction
{
actionGroup = None
}
}
}
MODULE
{
name = ModuleAnimateHeat
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
MODULE
{
name = ModuleAlternator
isEnabled = True
EVENTS
{
}
ACTIONS
{
}
}
RESOURCE
{
name = ElectricCharge
amount = 0
maxAmount = 0
flowState = True
isTweakable = False
hideFlow = True
flowMode = Both
}
}

Edited by Ezriilc
Updated Stages Demo ship file... again.
Link to comment
Share on other sites

My best guess is that dstg is the decoupler stage and istg is the activate stage.

Note that on the engine module they are different, I assume the decoupler goes in the stage right before the engine, so the fairing on the engine separates in the stage before the engine activates.

Everything else lines up if you assume that the istg is never called on the Decoupler and the Launch Stabilizers.

Testing required of course but that would be my first guess.

D.

Link to comment
Share on other sites

My best guess is that dstg is the decoupler stage and istg is the activate stage.

Note that on the engine module they are different, I assume the decoupler goes in the stage right before the engine, so the fairing on the engine separates in the stage before the engine activates.

Everything else lines up if you assume that the istg is never called on the Decoupler and the Launch Stabilizers.

Testing required of course but that would be my first guess.

D.

EDIT: Thank you very much for responding! I'm very grateful for all help.

I'm not sure what you mean. I've heard that dstg is the "decoupler stage", but I don't know what that really means. Can you break it down more for me?

What do you mean by "istg is never called"? Called by what?

EDIT: And what do you mean by "engine module"? Which MODULE? I don't see istg or dstg in any MODULE.

Something about this seems to completely escape me, in that I can't even understand what you're saying. I'm feeling extra thick today.

Edited by Ezriilc
Added another question.
Link to comment
Share on other sites

Based on my (updated) Stage Demo ship, I need to determine which stage each part is in from these values.

probeCoreHex_4294616496 
istg: 0
dstg: 0
miniFuelTank_4294616460
istg: 0
dstg: 0
liquidEngineMini_4294616432
istg: 0
dstg: 0
stackDecouplerMini_4294616362
istg: 0
dstg: 1
fuelTankSmallFlat_4294616336
istg: 2
dstg: 2
liquidEngine3_4294616306
istg: 1
dstg: 2
stackDecoupler_4294616220
istg: 1
dstg: 3
fuelTank4-2_4294616184
istg: 4
dstg: 4
mumech.MJ2.AR202_4294594312
istg: 0
dstg: 0
liquidEngine2-2_4294571248
istg: 2
dstg: 4
decoupler1-2_4294559564
istg: 2
dstg: 5
fuelTank4-2_4294559174
istg: 6
dstg: 6
liquidEngine2-2_4294559142
istg: 3
dstg: 6
decoupler1-2_4294552894
istg: 3
dstg: 7
fuelTank4-2_4294552824
istg: 8
dstg: 8
sepMotor1_4294542100
istg: 4
dstg: 8
sepMotor1_4294541692
istg: 4
dstg: 8
launchClamp1_4294534672
istg: 4
dstg: 8
launchClamp1_4294534432
istg: 4
dstg: 8
liquidEngine2-2_4294529886
istg: 5
dstg: 8

Edited by Ezriilc
Updated ship file... again.
Link to comment
Share on other sites

Okay, I'm assuming istg stands for "initialization stage" and dstg stands for "decoupler stage" or similar.

Note that these values are on the Part, not the PartModule.

To test this, do the istg values match the stage the part shows in the editor? Note that the stage may be reversed, with the highest numbered stage being the first stage activated when you launch.

Then certain parts, such as engines, have 2 "stages". The first stage, the istg, is the stage the engine activates in and is straightforward.

However, the second stage would not be visible to the player as it is the engine fairing separation and the dstg of the fairing would be inherited from the attached decoupler.

Then items which don't have stages, such as fuel tanks, command pods, etc. get a stage assigned when they are placed in the editor according to the normal rules, but they don't actually use the istg and dstg value for anything.

Then when the stage in question is activated, the part gets the trigger and sends the message down to all of it's partmodules.

Note this is all my best guess based on how I understand the background code to work, I have not actually tested any of this.

D.

edit: To clarify my previous post, I should have said engine part, not engine module.

edit the second: Parsing your demo ship you linked I'm actually now not sure, it looks like only the dstg value makes sense and is equal to the activating stage as shows in the staging icons on the side of the screen, but I have no clue what istg does.

It looks like the demo ship you linked, I see 9 stages total. The only wildcard is the two sepMotor1's that activate on the first press of the space bar.

So, I'm not sure what istg is, but dstg looks like the current stage of the part.

Edited by Diazo
Link to comment
Share on other sites

Thanks again for all your help, Diazo.

To clarify my previous post, I should have said engine part, not engine module.

Ah yes, thanks.

... it looks like only the dstg value makes sense and is equal to the activating stage as shows in the staging icons on the side of the screen, but I have no clue what istg does.

...

So, I'm not sure what istg is, but dstg looks like the current stage of the part.

Huh [lulz], I just came to the opposite conclusion - that istg is the only one I want. Could you be conflating i for d? By using only istg, I've had some success, but I suspect all that will go South, once I try parsing a different ship with different staging, like asspergrass.

It looks like the demo ship you linked, I see 9 stages total. The only wildcard is the two sepMotor1's that activate on the first press of the space bar.

Yes. I added the sepMotors that way to represent that very common arrangement - even Kerbal X has it.

Link to comment
Share on other sites

What really throws me is that the SepMotors have a dstg of 8 and an istg of 4.

8 is the highest stage number, so is the first stage activated when pressing space.

But no matter which way you go, from low to high, or high to low, 4 is in the middle. How does that translate in any form to being in the first stage activated?

Really confused on istg at this point. I am still assuming the stg part means stage, but no clue on what i means or what that variable does at this point.

D.

Link to comment
Share on other sites

EDIT: NathanKell, thanks for your input!

I do know istg is inverse stage, or so I recall. It should match up in inverse order.

That seems to make sense. Parsing "Kolsys 5.2 Explorer", and using the above logic with istg, I've got it "working" so far. Now to hit it with lots of different ships to see if I can break it.

What really throws me is that the SepMotors have a dstg of 8 and an istg of 4.

8 is the highest stage number, so is the first stage activated when pressing space.

But no matter which way you go, from low to high, or high to low, 4 is in the middle. How does that translate in any form to being in the first stage activated?

Really confused on istg at this point. I am still assuming the stg part means stage, but no clue on what i means or what that variable does at this point.

D.

Yea, I know, right? Thanks for summing up my frustrations in a nutshell. Every time I think I'm getting it, another ship's values blow my theories out of the water. [sigh] If the guys at MechJeb can get it, then so can I... in time... hopefully...

Edited by Ezriilc
I keep forgetting to thank people...
Link to comment
Share on other sites

So, what I've learned since posting here, is that by tracking "istg" on engines only, I'm able to accurately tell what stage is the launch stage. However, I have tested this with very few ships, so I'm still not sure of the technique.

Beyond that, I'd like a sure-fire method for determining and understanding the stage information - from a practicable stand-point - for all parts in a ship. Basically, the same that MechJeb does and shows in its Delta-V Stats window, with each stage's mass, TWR, etc..

I'm still hoping that others will jump in here and hook us up.

Link to comment
Share on other sites

How does that work?

From post 5 of this thread where you posted your demo ship istg and dstg values.

The SepMotors have an istg of 4 and a dstg of 8 on a ship with a maximum dstg of 8. You said that the SepMotors activate on the first press of the space bar, how does istg of 4 transfer to that?

D.

Link to comment
Share on other sites

How does that work?

From post 5 of this thread where you posted your demo ship istg and dstg values.

The SepMotors have an istg of 4 and a dstg of 8 on a ship with a maximum dstg of 8. You said that the SepMotors activate on the first press of the space bar, how does istg of 4 transfer to that?

D.

Good question. I'll do my best to explain what I've done.

Remember that I'm only tracking "istg", and only on engines; and that istg/dstg start at zero.

This ship has 6 stages (0-5), making 5 the first, and 4 the second and launch stage, which fires the sepMotors.

Here's the output of my script in its current state:

Data cache is older than 3600 secs or an update was forced; updating... 
Parsed game files in 1 seconds.
Wrote 211273 bytes to data cache.
Parsed data cache in 1 seconds.
Parsed ship in 0 seconds.
Ship stats calculated in 0 seconds.

[B]array[/B] [I](size=1)[/I]
'Stages Demo' [COLOR=#888a85]=>[/COLOR]
[B]array[/B] [I](size=17)[/I]
'version' [COLOR=#888a85]=>[/COLOR] string [COLOR=#cc0000]'0.23.0'[/COLOR] [I](length=6)[/I]
'description' [COLOR=#888a85]=>[/COLOR] string [COLOR=#cc0000]'A simple stack, for practice.'[/COLOR] [I](length=29)[/I]
'type' [COLOR=#888a85]=>[/COLOR] string [COLOR=#cc0000]'VAB'[/COLOR] [I](length=3)[/I]
'crew' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]0[/COLOR]
'parts' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]20[/COLOR]
'struts' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]0[/COLOR]
'engines' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]7[/COLOR]
'decouplers' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]4[/COLOR]
'clamps' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]2[/COLOR]
'stages' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]6[/COLOR]
'launch_stage' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]4[/COLOR]
'part_list' [COLOR=#888a85]=>[/COLOR]
[B]array[/B] [I](size=13)[/I]
'probeCoreHex' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'miniFuelTank' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'liquidEngineMini' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'stackDecouplerMini' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'fuelTankSmallFlat' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'liquidEngine3' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'stackDecoupler' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'fuelTank4-2' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]3[/COLOR]
'mumech_MJ2_AR202' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]1[/COLOR]
'liquidEngine2-2' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]3[/COLOR]
'decoupler1-2' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]2[/COLOR]
'sepMotor1' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]2[/COLOR]
'launchClamp1' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]2[/COLOR]
'mass' [COLOR=#888a85]=>[/COLOR] float [COLOR=#f57900]23.35[/COLOR]
'mass_dry' [COLOR=#888a85]=>[/COLOR] float [COLOR=#f57900]10.66751[/COLOR]
'mass_wet' [COLOR=#888a85]=>[/COLOR] float [COLOR=#f57900]12.683675[/COLOR]
'thrust' [COLOR=#888a85]=>[/COLOR] int [COLOR=#4e9a06]256[/COLOR]
'twr' [COLOR=#888a85]=>[/COLOR] float [COLOR=#f57900]1.12[/COLOR]
T+2 seconds[HR][/HR]

Here's my PHP if anyone's interested. Feel free to nit-pick my code - I like input.

<?php
class CraftKitchen{
static $parts_root = 'KSP/Parts';
static $data_file = 'game_data.cfg';
static $data_refresh = 3600;
static $game_data = array();
static $ships = array();

function __construct($craft){
$this->message = '';
if( is_file($craft) && is_readable($craft) ){ // File
$this->update();
$time = time();
$this->data = $this->text_to_array(file_get_contents($craft));
$this->message .= "Parsed ship in ".(time()-$time)." seconds. \r\n";
$time = time();
$this->ship_stats($this->data);
$this->message .= "Ship stats calculated in ".(time()-$time)." seconds. \r\n";
}elseif( $craft === 'update' ){
$this->update(true);
}
}

private function update($force=false){
if(
filemtime(static::$data_file) < (time() - static::$data_refresh)
||
$force
){
$this->message .= "Data cache is older than ".static::$data_refresh." secs or an update was forced; updating... \r\n";
$raw_data = array('parts'=>array());
$time = time();
foreach( scandir(static::$parts_root) as $part_cat ){
if( preg_match('/^(\.)|(\.\.)$/i',$part_cat) ){ continue; }
foreach( scandir(static::$parts_root.'/'.$part_cat) as $part_dir ){
if( preg_match('/^(\.)|(\.\.)$/i',$part_dir) ){ continue; }
$part_cfg = static::$parts_root.'/'.$part_cat.'/'.$part_dir.'/part.cfg';
$part_data = $this->text_to_array( file_get_contents($part_cfg) );
$part_data = $part_data['PART_0'];
$raw_data['parts'][$part_data['name_0']] = $part_data;
}
}
$this->message .= "Parsed game files in ".(time()-$time)." seconds. \r\n";
$raw_text = $this->array_to_text($raw_data);
if( $bytes = file_put_contents( static::$data_file, $raw_text ) ){
$this->message .= "Wrote ".$bytes." bytes to data cache. \r\n";
}else{
$this->message .= "ERROR: Write to data cache failed. \r\n";
}
}
if( !count(static::$game_data) ){
if( $data_file_text = file_get_contents(static::$data_file) ){
$time = time();
static::$game_data = $this->text_to_array( $data_file_text );
$this->message .= "Parsed data cache in ".(time()-$time)." seconds. \r\n";
}else{
$this->message .= "ERROR: Can't read data; no stats available. \r\n";
}
}
}

private function ship_stats($data){ // The meat of the sammich.
$this->stats = array();
$this->parts = array();
$this->engines = array();
// Import existing stats.
foreach($data as $key => $val){
if( preg_match('/PART/', $key) ){
$this->parts[] = $val;
}else{
$fixed_key = preg_replace('/_\d+/','',$key);
$this->stats[$fixed_key] = $val;
}
}
// Add some new stats.
$this->stats = array_merge($this->stats, array(
'crew'=>0
,'parts'=>0
,'struts'=>0
,'engines'=>0
,'decouplers'=>0
,'clamps'=>0
,'stages'=>0
,'launch_stage'=>0
,'part_list'=>array()
));
$stats = &$this->stats;
$first_engine_stage = 0;
$first_decoupler_stage = 0;
$first_clamp_stage = 0;
$name_id_patt = '^(.+)_(\d+)$';
if( isset(static::$game_data['parts_0']) ){
$game_parts = static::$game_data['parts_0'];
}
// First walkthrough.
foreach( $this->parts as $part_key => $part ){
$part_name = preg_filter('/'.$name_id_patt.'/','$1',$part['part_0']);
// $part_id = preg_filter('/'.$name_id_patt.'/','$2',$part['part_0']);
$part_name = preg_replace('/\./','_',$part_name);
$stats['parts']++;
if( !array_key_exists($part_name, $stats['part_list']) ){
$stats['part_list'][$part_name] = 1;
}else{
$stats['part_list'][$part_name]++;
}
if( preg_match('/launchClamp/i',$part_name) ){
$stats['clamps']++;
$first_clamp_stage = $part['istg_0']+0;
}elseif( preg_match('/strut/i',$part_name) ){
$stats['struts']++;
}elseif( preg_match('/engine|motor|booster|aerospike/i',$part_name) ){
$stats['engines']++;
$this->engines[] = &$this->parts[$part_key];
// Track highest/first engine "istg" stage:
if( $part['istg_0'] > $first_engine_stage ){
$first_engine_stage = $part['istg_0']+0;
}
}elseif( preg_match('/decoupler|separator/i',$part_name) ){
$stats['decouplers']++;
$this->decouplers[] = &$this->parts[$part_key];
// Track highest/first decoupler "istg" stage:
if( $part['istg_0'] > $first_decoupler_stage ){
$first_decoupler_stage = $part['istg_0']+0;
// Unused as of yet.
}
}
if( isset($part['CrewCapacity_0']) ){
$stats['crew'] += $part['CrewCapacity_0'];
}

if( isset($game_parts) ){
foreach( $game_parts as $game_part ){
if( preg_match('/'.$part_name.'/', $game_part['name_0']) ){
$this->parts[$part_key]['ref'] = &static::$game_data['parts_0'][$part_name.'_0'];
$part = $this->parts[$part_key];
}
}
}
if( ! isset($part['ref']) && isset($game_parts) ){
$this->$message .= "ERROR: Can't find part: ".$part_name." \r\n";
}
} // Finished first walkthrough.

$stats['stages'] = $first_engine_stage+1;
if( $first_clamp_stage ){
$stats['launch_stage'] = $first_clamp_stage;
}else{
$stats['launch_stage'] = $stats['stages']-1;
}

if( isset($game_parts) ){ // Parts data are available.
// Do the fancy stuff.
$this->stats = array_merge($this->stats, array(
'mass'=>0
,'mass_dry'=>0
,'mass_wet'=>0
,'thrust'=>0
,'twr'=>0
));
$stats = &$this->stats;
// Known resource masses in tonnes per litre:
$resources = array(
'SolidFuel'=>0.0075
,'LiquidFuel'=>0.005
,'Oxidizer'=>0.005
,'IntakeAir'=>0.005 // Really?
,'MonoPropellant'=>0.004
,'XenonGas'=>0.0001
,'ElectricCharge'=>0 // For my pseudo-OCD.
);
// Second walkthrough, for GameData.
foreach( $this->parts as $part_key => $part ){
if( preg_match('/^launchClamp1_\d+$/',$part['part_0']) ){
// $this->message .= "Clamp found and ignored for mass.\r\n";
}else{
// Count masses.
$stats['mass_dry'] += @$part['ref']['mass_0']+0;
foreach( $part['ref'] as $ref_key => $ref_val ){
if( preg_match('/RESOURCE/',$ref_key) ){
$resource = $ref_val['name_0'];
$amount = $ref_val['amount_0'];
if( array_key_exists($resource,$resources) ){
$stats['mass_wet'] += ($amount*$resources[$resource]);
}else{
$this->message .= "Unknown resource: ".$resource."\r\n";
}
}
}
}
} // Finished second walkthrough.

foreach( $this->engines as $engine_key => $engine ){
if( // ASL thrust from launch stage and before only.
$engine['istg_0'] >= $stats['launch_stage']
){
$thrust_additive = 0;
foreach( $engine['ref'] as $ref_key => $ref_val ){
if(
preg_match('/ModuleEngines/', @$ref_val['name_0'])
&&
@$ref_val['engineID_0'] !== 'ClosedCycle'
){
$thrust_additive += $ref_val['maxThrust_0'];
}
}
// Correct thrust for actual ASL performance.
/*
if( preg_match('/JetEngine/', $engine['part_0']) ){
$thrust_additive = 135;
}elseif( preg_match('/turboFanEngine/', $engine['part_0']) ){
$thrust_additive = 110;
}elseif( preg_match('/RAPIER/', $engine['part_0']) ){
$thrust_additive = 90;
}
*/
$stats['thrust'] += $thrust_additive;
}
}
$stats['mass'] = $stats['mass_wet']+$stats['mass_dry'];
$stats['twr'] = ( $stats['thrust'] / ($stats['mass']*9.80665) );
$stats['mass'] = round( $stats['mass'], 2 );
$stats['twr'] = round( $stats['twr'], 2 );
}
static::$ships[$this->stats['ship']] = $this->stats;
array_shift(static::$ships[$this->stats['ship']]);
}

private function array_to_text($data, $depth=0){ // Recursive, must remain isolated.
$return = '';
$indent = '';$i=0;while($i<$depth){$indent .= "\t";$i++;}
$end = "\r\n";
$last_key = '';
foreach( $data as $key => $val ){
$key = preg_replace('/_\d+/i', '', $key);
$return .= $indent.$key;
if( is_array($val) ){
$return .= $end.$indent.'{'.$end;
$depth++;
$return .= $this->array_to_text($val,$depth--);
$return .= $indent.'}'.$end;
}else{
$return .= ' = '.$val.$end;
}
}
return $return;
}

private function text_to_array($text){ // This was/is the hard part.
$return = array();
$patts = array(
'header'=>'/^\s*([^=\{\}]+)\s*\{?\s*$/i'
,'property'=>'/^\s*([^=\{\}]+)\s*=\s*[^\{\}]*\s*$/i'
,'value'=>'/^\s*[^=\{\}]+\s*=\s*([^\{\}]*)\s*$/i'
,'open'=>'/^\s*(\{)\s*$/i' // Not used, but handy.
,'close'=>'/^\s*(\}|\))\s*$/i'
);
$stack = array( &$return ); // $stack & $pointer together track depth.
$pointer = &$stack[count($stack)-1];

$lines = explode("\n", $text);
foreach($lines as $line){
$line = preg_replace('/\/\/.*/i', '', $line); // Remove comments
$line = preg_replace('/\x{EF}\x{BB}\x{BF}/','',$line); // Remove BOM.
if( !trim($line) ){ continue; } // Ignore blanks.
$line_array = array();
$result = '';
foreach( $patts as $patt_key => $patt ){
$line_array[$patt_key] = rtrim(preg_filter($patt, '$1', $line));
if( $line_array[$patt_key] === '' ){
unset($line_array[$patt_key]);
}else{
$result = $patt_key;
}
}
$line = $line_array;

if( $result === 'header' ){
$header = $line['header'];
$header_count = 0;
foreach($pointer as $pointer_key => $pointer_val){
if( preg_match('/'.$header.'/',$pointer_key) ){
$header_count++;
}
}
$pointer[$header.'_'.$header_count] = array();

$stack[] = &$pointer[$header.'_'.$header_count]; // Deeper.
$pointer = &$stack[count($stack)-1];
}

if( $result === 'property' || $result === 'value' ){
$property = isset($line['property']) ? $line['property'] : '';
$value = isset($line['value']) ? $line['value'] : '';
$property_count = 0;
foreach($pointer as $pointer_key => $pointer_val){
if( preg_match('/'.$property.'/',$pointer_key) ){
$property_count++;
}
}
$pointer[$property.'_'.$property_count] = $value;
}

if( $result === 'close' ){
array_pop($stack); // Shallower.
$pointer = &$stack[count($stack)-1];
}
}
return $return;
}
/* END OF CLASS */
}

echo "<pre>";

$craft = new CraftKitchen("Stages Demo.craft");
echo $craft->message;
var_dump(CraftKitchen::$ships);
echo "T+".(time()-$_SERVER['REQUEST_TIME']).' seconds<hr/>';

?>

Edited by Ezriilc
Updated PHP code and output.
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...