Infernal Robotics¶
- Download: http://kerbal.curseforge.com/ksp-mods/220267
- Alternative download: https://github.com/MagicSmokeIndustries/InfernalRobotics/releases
- Forum thread, including full instructions: http://forum.kerbalspaceprogram.com/index.php?/topic/104535-/
Infernal Robotics might not be installed on your copy of the game.
Your script can test whether or not it’s installed by using
the boolean expression addons:available("ir").
Infernal Robotics introduces robotics parts to the game, letting you create moving or spinning contraptions that just aren’t possible under stock KSP.
Starting version 0.20 of the Infernal Robotics, mod creators introduced API to for easier access to robotic features.
Access structure IRAddon via ADDONS:IR.
-
structure
IRAddon¶ Suffix Type Description AVAILABLEboolean (readonly) Returns True if mod Infernal Robotics is installed, available to KOS and applicable to current craft. It is better to use addons:available("rt").GROUPSList of IRControlGroupLists all Servo Groups for the Vessel on which CPU runs this command (see details below). ALLSERVOSList of IRServoLists all Servos for the Vessel on which CPU runs this command (see details below). PARTSERVOS(Part)List of IRServoLists all Servos for the provided part
-
IRAddon:
AVAILABLE¶ Type: BooleanAccess: Get only It is better to first call
ADDONS:AVAILABLE("IR")to find out if the plugin exists.Returns True if mod Infernal Robotics is installed, available to KOS and applicable to current craft. Example of use:
if ADDONS:IR:AVAILABLE { //some IR dependent code }
-
IRAddon:
GROUPS¶ Type: ListofIRControlGroupobjectsAccess: Get only Lists all Servo Groups for the Vessel on which the script is being executed. On IR versions prior to 0.21.5 will always return servo groups for current focused vessel. Example of use:
for g in ADDONS:IR:GROUPS { Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos". }
-
IRAddon:
ALLSERVOS¶ Type: ListofIRServoobjectsAccess: Get only Lists all Servos for the Vessel on which the script is being executed. On IR versions prior to 0.21.5 will always return servos for current focused vessel. Example of use:
for s in ADDONS:IR:ALLSERVOS { print "Name: " + s:NAME + ", position: " + s:POSITION. }
-
IRAddon:
PARTSERVOS(part)¶ Parameters: - part –
Partfor which to return servos
Return type: Lists all Servos found on the given
Part.- part –
-
structure
IRControlGroup¶ Suffix Type Description NAMEstring Name of the Control Group SPEEDscalar Speed multiplier set in the IR UI EXPANDEDBoolean True if Group is expanded in IR UI FORWARDKEYstring Key assigned to forward movement REVERSEKEYstring Key assigned to reverse movement SERVOSList (readonly) List of servos in the group VESSELVesselVessel object, owning this servo group. Readonly, requires IR version 0.21.5 or later. MOVERIGHT()void Commands servos in the group to move in positive direction MOVELEFT()void Commands servos in the group to move in negative direction MOVECENTER()void Commands servos in the group to move to default position MOVENEXTPRESET()void Commands servos in the group to move to next preset MOVEPREVPRESET()void Commands servos in the group to move to previous preset STOP()void Commands servos in the group to stop
-
IRControlGroup:
SPEED¶ Type: scalar Access: Get/Set Speed multiplier as set in the IR user interface. Avoid setting it to 0.
-
IRControlGroup:
FORWARDKEY¶ Type: string Access: Get/Set Key assigned to forward movement. Can be empty.
-
IRControlGroup:
REVERSEKEY¶ Type: string Access: Get/Set Key assigned to reverse movement. Can be empty.
-
IRControlGroup:
SERVOS¶ Type: List of IRServoobjectsAccess: Get only Lists Servos in the Group. Example of use:
for g in ADDONS:IR:GROUPS { Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos:". for s in g:servos { print " " + s:NAME + ", position: " + s:POSITION. } }
-
IRControlGroup:
VESSEL¶ Type: VesselAccess: Get only If IR 0.21.5 or later is installed will return a Vessel that owns this ServoGroup, otherwise will return current focused Vessel
-
IRControlGroup:
MOVERIGHT()¶ Returns: void Commands servos in the group to move in positive direction.
-
IRControlGroup:
MOVELEFT()¶ Returns: void Commands servos in the group to move in negative direction.
-
IRControlGroup:
MOVECENTER()¶ Returns: void Commands servos in the group to move to default position.
-
IRControlGroup:
MOVENEXTPRESET()¶ Returns: void Commands servos in the group to move to next preset
-
IRControlGroup:
MOVEPREVPRESET()¶ Returns: void Commands servos in the group to move to previous preset
-
IRControlGroup:
STOP()¶ Returns: void Commands servos in the group to stop
-
structure
IRServo¶ Suffix Type Description NAMEstring Name of the Servo UIDscalar (int) Unique ID of the servo part (part.flightID). HIGHLIGHTBoolean (set-only) Set Hightlight status of the part. POSITIONscalar (readonly) Current position of the servo. MINCFGPOSITIONscalar (readonly) Minimum position for servo as defined by part creator in part.cfg MAXCFGPOSITIONscalar (readonly) Maximum position for servo as defined by part creator in part.cfg MINPOSITIONscalar Minimum position for servo, from tweakable. MAXPOSITIONscalar Maximum position for servo, from tweakable. CONFIGSPEEDscalar (readonly) Servo movement speed as defined by part creator in part.cfg SPEEDscalar Servo speed multiplier, from tweakable. CURRENTSPEEDscalar (readonly) Current Servo speed. ACCELERATIONscalar Servo acceleration multiplier, from tweakable. ISMOVINGBoolean (readonly) True if Servo is moving ISFREEMOVINGBoolean (readonly) True if Servo is uncontrollable (ex. docking washer) LOCKEDBoolean Servo’s locked status, set true to lock servo. INVERTEDBoolean Servo’s inverted status, set true to invert servo’s axis. PARTPartA reference to a Part containing servo module. MOVERIGHT()void Commands servo to move in positive direction MOVELEFT()void Commands servo to move in negative direction MOVECENTER()void Commands servo to move to default position MOVENEXTPRESET()void Commands servo to move to next preset MOVEPREVPRESET()void Commands servo to move to previous preset STOP()void Commands servo to stop MOVETO(position, speedMult)void Commands servo to move to position with speedMult multiplier
-
IRServo:
MINCFGPOSITION¶ Type: scalar Access: Get Minimum position for servo as defined by part creator in part.cfg
-
IRServo:
MAXCFGPOSITION¶ Type: scalar Access: Get Maximum position for servo as defined by part creator in part.cfg
-
IRServo:
CONFIGSPEED¶ Type: scalar Access: Get Servo movement speed as defined by part creator in part.cfg
-
IRServo:
INVERTED¶ Type: Boolean Access: Get/Set Servo’s inverted status, set true to invert servo’s axis.
-
IRServo:
PART¶ Type: PartAccess: Get Returns reference to the
Partcontaining servo module. Please note that Part:UID does not equal IRServo:UID.
-
IRServo:
MOVERIGHT()¶ Returns: void Commands servo to move in positive direction
-
IRServo:
MOVELEFT()¶ Returns: void Commands servo to move in negative direction
-
IRServo:
MOVECENTER()¶ Returns: void Commands servo to move to default position
-
IRServo:
MOVENEXTPRESET()¶ Returns: void Commands servo to move to next preset
-
IRServo:
MOVEPREVPRESET()¶ Returns: void Commands servo to move to previous preset
-
IRServo:
STOP()¶ Returns: void Commands servo to stop
-
IRServo:
MOVETO(position, speedMult)¶ Parameters: - position – (float) Position to move to
- speedMult – (float) Speed multiplier
Returns: void
Commands servo to move to position with speedMult multiplier.
Example code:
print "IR Iavailable: " + ADDONS:IR:AVAILABLE.
Print "Groups:".
for g in ADDONS:IR:GROUPS
{
Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos:".
for s in g:servos
{
print " " + s:NAME + ", position: " + s:POSITION.
if (g:NAME = "Hinges" and s:POSITION = 0)
{
s:MOVETO(30, 2).
}
else if (g:NAME = "Hinges" and s:POSITION > 0)
{
s:MOVETO(0, 1).
}
}
}