Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Action handlers

MOARdV edited this page Mar 3, 2014 · 10 revisions

Action handlers are plugins for JSIActionGroupSwitch, allowing you to tie in-IVA animated switches provided by this module to foreign execution code. There isn't that much need for this feature externally, but internally RasterPropMonitor components use it to tie interface plugins into the framework.

The plugin mode is enabled by giving 'plugin' as the action name:

actionName = plugin

When this is present, the PLUGINACTION blocks in the module configuration are parsed. Multiple blocks will be parsed, until one loads successfully:

	PLUGINACTION
	{
		name = MechJebRPMButtons
		actionMethod = ButtonRetrograde
		stateMethod = ButtonRetrogradeState
	}
  • name -- is the name of the module to load.
  • actionMethod -- The name of the method to call on the module when button state changes.
  • stateMethod -- The name of the method to call on the module to determine which state the button is actually in. This parameter is optional, if it is not present, JSIActionGroupSwitch will track the button state itself.

If no block resulted in a successful module instance, the switch will be treated as if the action name was dummy.

To create your own action handler, you need to know these things:

  • The handler must be an InternalModule. Only one copy will be created per prop if multiple instances of JSIActionGroupSwitch are present in it, and it must survive calls by multiple copies.
  • The actionMethod is a void method that takes one bool parameter -- true if the switch is to be turned on, and false if the switch is to be turned off.
  • The stateMethod is a method that takes no parameters and returns a bool value -- true if the switch is currently in the 'on' state and false if it's in the off state. If this method is not provided, JSIActionGroupSwitch will keep track of the current state of the switch itself -- use it if the state of your action cannot change independently of the switch.

Builtin action handlers

JSIInternalRPMButtons

This module is part of the core RPM DLL. It provides access to some functionality that can be implemented without using external plugins.

  • ButtonActivateReserves/ButtonActivateReservesState -- Turns on all resources that were disabled by the player (for instance, by right-clicking on a monopropellant tank, and clicking on the small icon next to the tank's capacity to prevent it from being used). The button is 'on' when there is at least one resource whose flow was disabled.
  • ButtonClearNodes/ButtonClearNodesState -- Clears all maneuver nodes on the current vessel. The button is 'on' when there is at least one valid maneuver node.
  • ButtonClearTarget/ButtonClearTargetState -- Clears the current target. The button is 'on' when there is a valid target.
  • ButtonEnableEngines/ButtonEnableEnginesState -- Turns on all engines on the current stage, the same as right-clicking each engine and selecting "Activate". When engines are on, the button turns off all engines on any stage that have been activated and can be turned off (SRBs, for instance, are not affected).
  • ButtonSpeedMode/ButtonSpeedModeState -- Toggles the speed mode between orbital, surface, and target. The button is 'on' at all times.
  • ButtonStageLock/ButtonStageLockState -- Toggles stage locking (preventing staging), the same as alt-L. The button is 'on' when staging is locked, and off otherwise.

MechJebRPMButtons

This module is part of MechJebRPM.dll and provides access to SmartASS and other functions with pairs of actionMethod/stateMethod:

  • ButtonAscentGuidance/ButtonAscentGuidanceState -- Ascent autopilot button. Pressing this button will turn ascent autopilot on. The button is in the 'on' state while the ascent autopilot is active.
  • ButtonEnableLandingPrediction/ButtonEnableLandingPredictionState -- Enables the MechJeb Landing Guidance prediction system. This system estimates where the vessel will land, and how far from its target that landing will be. When Land at Target is enabled, this function is automatically engaged. The button state is on when the prediction system is on. To get a better idea why you might want to use this, take a look at MechJebRPMVariable.
  • ButtonForceRoll/ButtonForceRollState -- Enable the SmartASS Force Roll button. The button state is on when Force Roll is active.
  • ButtonForceRoll0/ButtonForceRoll0State -- Enables Force Roll, and sets the orientation to 0. The button state is on when Force Roll is engaged, and the roll is set to 0.
  • ButtonForceRoll90/ButtonForceRoll90State -- Enables Force Roll, and sets the orientation to +90. The button state is on when Force Roll is engaged, and the roll is set to +90.
  • ButtonForceRoll180/ButtonForceRoll180State -- Enables Force Roll, and sets the orientation to 180. The button state is on when Force Roll is engaged, and the roll is set to 180.
  • ButtonForceRoll270/ButtonForceRoll270State -- Enables Force Roll, and sets the orientation to -90. The button state is on when Force Roll is engaged, and the roll is set to -90.
  • ButtonKillRot/ButtonKillRotState -- KILL ROT
  • ButtonLandingGuidance/ButtonLandingGuidanceState -- Engage the MechJeb Landing Guidance pilot. If a valid ground target is targeted, this button acts as "Land at Target". Otherwise, this button acts as "Land Somewhere". The button is in the 'on' state when the landing pilot is enabled.
  • ButtonNode/ButtonNodeState -- NODE
  • ButtonNodeExecute/ButtonNodeExecuteState -- Node execution button. Pressing this button will execute the next maneuver node if one exists. The button is in the 'on' state while the node is being executed.
  • ButtonNormalMinus/ButtonNormalMinusState -- NML-
  • ButtonNormalPlus/ButtonNormalPlusState -- NML+
  • ButtonOff/ButtonOffState -- OFF
  • ButtonParMinus/ButtonParMinusState -- PAR-
  • ButtonParPlus/ButtonParPlusState -- PAR+
  • ButtonPlotHohmannTransfer/ButtonPlotHohmannTransferState -- Plot a Hohmann transfer orbit and create a maneuver node for it to the selected target (either a target in the same SoI, or another planet when orbiting a planet). The button is in the 'on' state (and functional) when a valid target is selected, and the ship is not in a highly elliptical orbit, and neither ship nor target are in hyperbolic orbits.
  • ButtonPrograde/ButtonProgradeState -- PROGRADE
  • ButtonRadialMinus/ButtonRadialMinusState -- RAD-
  • ButtonRadialPlus/ButtonRadialPlusState -- RAD+
  • ButtonRendezvousAutopilot/ButtonRendezvousAutopilotState -- Engages the Rendezvous Autopilot. The ship must be targeting a docking port for this mode to activate. The button is "on" when the autopilot is engaged.
  • ButtonRetrograde/ButtonRetrogradeState -- RETROGRADE
  • ButtonRvelMinus/ButtonRvelMinusState -- RVEL-
  • ButtonRvelPlus/ButtonRvelPlusState -- RVEL+
  • ButtonTargetMinus/ButtonTargetMinusState -- TGT-
  • ButtonTargetPlus/ButtonTargetPlusState -- TGT+