Skip to content

Events

These are the event types most mod authors care about first.

Client instance events

EventBest forExample use
ClientInstanceEventclient accesskeep a reference to the active client
CancelableClientInstanceEventblocking an actionstop something before it continues
ClientInstanceUpdateEventstartup / init flowrun code after init finishes

Example

cpp
CampAPI::ModuleScope scope;

scope.AddListener<ClientInstanceUpdateEvent>([](ClientInstanceUpdateEvent& event) {
    if (event.mIsInitFinished) {
        // start your feature here
    }
});

Input events

EventBest forExample use
InputEventinput handlingmark input as consumed
OnTouchEventtouch inputreact to taps and drags
OnKeyEventkeyboard inputreact to a specific key

Example

cpp
CampAPI::ModuleScope scope;

scope.AddListener<OnTouchEvent>([](OnTouchEvent& event) {
    if (event.action == 0) {
        event.Consume();
    }
});

Render events

EventBest forExample use
BeforeRenderScreenEventpre-render logiccancel a screen render
AfterRenderScreenEventpost-render logicdraw or log after screen output
GetSplashTextEventtext replacementchange the startup splash text

Example

cpp
CampAPI::ModuleScope scope;

scope.AddListener<GetSplashTextEvent>([](GetSplashTextEvent& event) {
    event.setText(std::string("CampAPI is running"));
});

Resource pack events

EventBest forExample use
RPMConstructorresource-pack setupinspect or prepare the manager

Example

cpp
CampAPI::ModuleScope scope;

scope.AddListener<RPMConstructor>([](RPMConstructor& event) {
    if (event.mNeedsToInitialize) {
        // prepare your resource-related logic here
    }
});