Stages
A mission is a sequence of stages. Each stage has an objective, the actions it runs, the branches that decide where it goes next, and optionally a reward. This page covers reaching, editing, and creating stages.
The stage list
A mission's stages are on mission.missionStages, an indexed list keyed by stage name. You reach a stage by name and edit it, the same way as any indexed list:
PM.Missions:Patch("RetuneStageObjective")
:Named("KSP2Mission_Main_Mun_01")
:Do(function(mission)
mission.missionStages:Patch("Land", function(stage)
stage.Objective = "Land softly on the Mun"
stage.DisplayObjective = true
end)
end)You can also iterate the stages with pairs when you want to touch all of them.
What is on a stage
The fields you most often set:
ObjectiveandDisplayObjectivecontrol the objective text shown to the player.actionsis the list of actions the stage runs.branchesis the list of branches, each pairing a condition with the stage it transitions to.MissionReward,MissionRewardType, andRewardAmountconfigure the payout. See below.
Creating a stage
PM.Missions:CreateStage(name, callback) builds a new stage and runs your callback to configure it. You then add it to a mission's stage list. Building a complete, working stage means filling in its objective, actions, and branches, so this is more involved than editing one. Copying the form of a stage from an existing mission is the reliable starting point, and the patch cache holds those missions' final JSON to copy from.
Rewards
A stage's reward is on stage.MissionReward, whose definitions are an indexed list keyed by reward type (MissionRewardType). The simple science-point payout is also expressible through the stage's MissionRewardType and RewardAmount fields directly. For anything richer, edit the MissionReward definitions list.
mission.missionStages:Patch("Complete", function(stage)
stage.MissionRewardType = "SciencePoints"
stage.RewardAmount = "50" -- RewardAmount is a string field, so the number is quoted
end)