Skip to content

[CPLUS plus Ex] Events and Hooks

DasKeifer edited this page Sep 30, 2026 · 3 revisions

Events and Hooks

CPLUS+ Ex fires events when skill states change. These events allow mods to respond to skill assignments and state changes.

CPLUS+ Ex implemented Events/Hooks

Events vs Hooks

Each trigger can be used as a event or a hook

  1. Event Object - cplus_plus_ex.events.on<EventName>:subscribe(callback) - ModLoader Event subscription pattern that is never cleared
  2. Hook Function - cplus_plus_ex:add<EventName>Hook(callback) - Hook registration cleared each time mods are loaded (singular Hook, not Hooks)

CPLUS+ Ex Triggers

SkillEnabled

Event: cplus_plus_ex.events.onSkillEnabled:subscribe(callback)
Hook: cplus_plus_ex:addSkillEnabledHook(callback)

Fired when a skill is enabled or disabled in configuration.

Event Arguments

Argument name Type Description
skillId string The skill ID
isEnabled boolean true if enabled, false if disabled

Using the Event

cplus_plus_ex.events.onSkillEnabled:subscribe(function(skillId, isEnabled)
    LOG("Skill " .. skillId .. " is now " .. (isEnabled and "enabled" or "disabled"))
end)

SkillInRun

Event: cplus_plus_ex.events.onSkillInRun:subscribe(callback)
Hook: cplus_plus_ex:addSkillInRunHook(callback)

Fired when a skill is added to or removed for any pilot in this run (in mech or in storage/pod/perfect island reward).

Event Arguments

Argument name Type Description
skillId string The skill ID
isInRun boolean true if added, false if removed
pilot Pilot memhack Pilot struct
skillStruct PilotLvlUpSkill memhack skill struct

Using the Event

cplus_plus_ex.events.onSkillInRun:subscribe(function(skillId, isInRun, pilot, skillStruct)
    LOG("Skill " .. skillId .. " on pilot " .. pilot:getIdStr() .. " is now " .. (isInRun and "in run" or "no longer in run"))
end)

SkillActive

Event: cplus_plus_ex.events.onSkillActive:subscribe(callback)
Hook: cplus_plus_ex:addSkillActiveHook(callback)

Fired when a skill becomes active or inactive (pilot enters/leaves mech or on level up).

Event Arguments

Argument name Type Description
skillId string The skill ID
isActive boolean true if became active, false if inactive
pawnId number Mech ID (0-2)
pilot Pilot memhack Pilot struct
skillStruct PilotLvlUpSkill memhack skill struct

Using the Event

cplus_plus_ex.events.onSkillActive:subscribe(function(skillId, isActive, pawnId, pilot, skillStruct)
    LOG("Skill " .. skillId .. " on mech " .. pawnId .. " is now " .. (isActive and "active" or "inactive"))
end)

PreAssigningLvlUpSkills

Event: cplus_plus_ex.events.onPreAssigningLvlUpSkills:subscribe(callback)
Hook: cplus_plus_ex:addPreAssigningLvlUpSkillsHook(callback)

Fired before CPLUS+ begins assigning level up skills to pilots. This event fires once per assignment batch (e.g., when applying skills to all pilots at mission start).

Event Arguments

None.

Using the Event

cplus_plus_ex.events.onPreAssigningLvlUpSkills:subscribe(function()
    LOG("About to assign skills to pilots")
end)

SkillsSelected

Event: cplus_plus_ex.events.onSkillsSelected:subscribe(callback)
Hook: cplus_plus_ex:addSkillsSelectedHook(callback)

Fired for each pilot BEFORE their skills are applied to memory in between the pre and post AssigningLvlUpSkills events

Event Arguments

Argument name Type Description
pilot Pilot memhack Pilot struct
skillId1 string First skill ID selected
skillId2 string Second skill ID selected

Using the Event

cplus_plus_ex.events.onSkillsSelected:subscribe(function(pilot, skillId1, skillId2)
    LOG(pilot:getNameStr() .. " will get " .. skillId1 .. " and " .. skillId2)
end)

PostAssigningLvlUpSkills

Event: cplus_plus_ex.events.onPostAssigningLvlUpSkills:subscribe(callback)
Hook: cplus_plus_ex:addPostAssigningLvlUpSkillsHook(callback)

Fired after CPLUS+ finishes assigning level up skills to pilots. This event fires once per assignment batch.

Event Arguments

None.

Using the Event

cplus_plus_ex.events.onPostAssigningLvlUpSkills:subscribe(function()
    LOG("Finished assigning skills to pilots")
end)

ExtraInfoSelectedChanged

Event: cplus_plus_ex.events.onExtraInfoSelectedChanged:subscribe(callback)
Hook: cplus_plus_ex:addExtraInfoSelectedChangedHook(callback)

Fired when the extra info panel (showing virtual skills and other info) is displayed for a pawn (or it changes). See sgt. Drake for an actual example

Event Arguments

Argument name Type Description
ui table The UI object for adding info to
pawn BoardPawn Vanilla pawn object of the selected pawn
pilot Pilot memhack Pilot of the pawn or nil if no pilot

Using the Event

cplus_plus_ex.events.onExtraInfoSelectedChanged:subscribe(function(ui, pawn, pilot)
    LOG("Showing extra info for pawn "..pawn:GetId())
end)

Clone this wiki locally