Skip to content

modkit

sdk/modkit/ contains helper libraries for mods. Include a library with a quoted #include (for example, #include "modkit/text.c"). Generated by dc2tk api-docs from the SDK's headers; change the headers, not this page.

modkit/input.c

modkit input: button polling and waiting helpers for event (map) scripts. Include with #include "modkit/input.c". Button masks use the PAD_ constants from <event.h>.

modkit_wait

Waits the given number of frames.

void modkit_wait(int frames)
{
    while (frames-- > 0) {
        WAIT();
    }
}

modkit_pressed

Returns the buttons in mask pressed this frame, or 0 if none were pressed.

int modkit_pressed(int mask)
{
    return get_pad_pressed() & mask;
}

modkit_wait_for_button

Waits until a button in mask is newly pressed and returns the pressed button mask.

int modkit_wait_for_button(int mask)
{
    int pressed;

    WAIT();
    while (!(pressed = get_pad_pressed() & mask)) {
        WAIT();
    }
    return pressed;
}

modkit_wait_for_confirm

Waits for (X) or (O).

void modkit_wait_for_confirm(void)
{
    modkit_wait_for_button(PAD_CROSS | PAD_CIRCLE);
}

modkit/text.c

modkit text: message window helpers for event (map) scripts. Include with #include "modkit/text.c".

Displays text immediately in the top hint slot without a button prompt. Supports standard message formatting codes: [Number1] to [Number16] (set with set_message_value before displaying the text), button icons such as (X), (O), [r1], and [select], \n for line breaks, and <page> for page breaks (see docs/internals/running.md).

modkit_text_open

Configures window for script-controlled text display.

void modkit_text_open(int window)
{
    apply_message_preset(window, MES_PRESET_WINDOW);
    set_message_window_mode(window, MES_WIN_VERSATILE_1);
    set_message_speed(window, 0);
    set_message_prompt(window, 0);
}

modkit_text_show

Displays text in window, replacing any existing text.

void modkit_text_show(int window, string text)
{
    show_message(window, text);
    show_message(window, -1);
    set_message_slot(window, 8);
    place_message_bubble(window, 0, 0, 0, 0);
}

modkit_text_close

Closes window and restores the default button prompt.

void modkit_text_close(int window)
{
    set_message_prompt(window, 1);
    set_message_cursor(window, -1);
    close_message(window);
    set_message_slot(window, 0);
}

modkit_say

Displays text in window 0 until the player presses (X) or (O), then closes the window.

void modkit_say(string text)
{
    modkit_text_open(0);
    modkit_text_show(0, text);
    modkit_wait(10);
    modkit_wait_for_confirm();
    modkit_text_close(0);
}

modkit_caption

Displays text in window 0 and keeps it on screen during gameplay until modkit_text_close(0) is called.

void modkit_caption(string text)
{
    modkit_text_open(0);
    modkit_text_show(0, text);
}

modkit/tick.c

modkit tick: runs a map event program on a repeating timer during combat. Include with #include "modkit/tick.c" in a monster AI patch, and call modkit_tick from a #pragma every_frame function.

Because a map event program that does not execute WAIT(); finishes in a single frame without pausing player control, monster scripts can use run_event_script to update live HUD captions or run periodic checks (see docs/scripting/tutorials/captions.md).

modkit_tick

While save flag flag is non-zero, triggers map event program every frames frames (25 FPS on PAL).

void modkit_tick(int flag, int frames, int program)
{
    int on;
    int timer;

    on = get_dungeon_flag(flag);
    if (on) {
        timer = get_floor_timer();
        if (timer >= frames) {
            reset_floor_timer();
            run_event_script(program);
        }
    }
}