Repository navigation
[CPLUS plus Ex] Events and Hooks
CPLUS+ Ex fires events when skill states change. These events allow mods to respond to skill assignments and state changes.
- SkillEnabled
- SkillInRun
- SkillActive
- PreAssigningLvlUpSkills
- SkillsSelected
- PostAssigningLvlUpSkills
- extraInfoSelectedChanged
Each trigger can be used as a event or a hook
- Event Object -
cplus_plus_ex.events.on<EventName>:subscribe(callback)- ModLoader Event subscription pattern that is never cleared - Hook Function -
cplus_plus_ex:add<EventName>Hook(callback)- Hook registration cleared each time mods are loaded (singularHook, notHooks)
Event: cplus_plus_ex.events.onSkillEnabled:subscribe(callback)
Hook: cplus_plus_ex:addSkillEnabledHook(callback)
Fired when a skill is enabled or disabled in configuration.
| Argument name | Type | Description |
|---|---|---|
skillId |
string | The skill ID |
isEnabled |
boolean | true if enabled, false if disabled |
cplus_plus_ex.events.onSkillEnabled:subscribe(function(skillId, isEnabled)
LOG("Skill " .. skillId .. " is now " .. (isEnabled and "enabled" or "disabled"))
end)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).
| 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 |
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)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).
| 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 |
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)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).
None.
cplus_plus_ex.events.onPreAssigningLvlUpSkills:subscribe(function()
LOG("About to assign skills to pilots")
end)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
| Argument name | Type | Description |
|---|---|---|
pilot |
Pilot | memhack Pilot struct |
skillId1 |
string | First skill ID selected |
skillId2 |
string | Second skill ID selected |
cplus_plus_ex.events.onSkillsSelected:subscribe(function(pilot, skillId1, skillId2)
LOG(pilot:getNameStr() .. " will get " .. skillId1 .. " and " .. skillId2)
end)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.
None.
cplus_plus_ex.events.onPostAssigningLvlUpSkills:subscribe(function()
LOG("Finished assigning skills to pilots")
end)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
| 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 |
cplus_plus_ex.events.onExtraInfoSelectedChanged:subscribe(function(ui, pawn, pilot)
LOG("Showing extra info for pawn "..pawn:GetId())
end)