1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* SPDX-License-Identifier: MIT */
/*
* konrmplugin.h
*
* Copyright (c) 2026 KonAki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef KONRMPLUGIN_H
#define KONRMPLUGIN_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*** definition ***/
/* plugin commands of RPG Maker games (356 in MV, 357 in MZ), the way mzscript writes them. what a plugin does is its own JavaScript,
which is never run, so each command a game uses is something you answer yourself, by name. you hand over a table of names and
functions. a name with a NULL function is known and does nothing, for the ones that only dress up the original. a command that
is not in the table does nothing too, but is counted, so you can see what a game still needs */
#define KON_RM_PLUGIN_ARGS 16
#define KON_RM_PLUGIN_MISSED 64
/* argv[0] is the command and argc counts it, the rest are what came after, apart by spaces in MV and by tabs in MZ (where the
command is the plugin, a dot, then the command). they are only good while the function runs. return 1 when the script is to wait */
typedef int (*kon_rmPluginFn)(int argc, const char *const *argv, void *user);
typedef struct kon_rmPluginEntry {
const char *name;
kon_rmPluginFn fn;
} kon_rmPluginEntry_t;
typedef struct kon_rmPlugins {
const kon_rmPluginEntry_t *entries;
int count;
void *user;
struct {
char name[48];
int count;
} missed[KON_RM_PLUGIN_MISSED];
int missedCount; /* kinds written down in missed */
int missedTotal; /* all of the commands that were not in the table */
} kon_rmPlugins_t;
void kon_rmPluginsInit(kon_rmPlugins_t *plugins, const kon_rmPluginEntry_t *entries, int count, void *user);
/* returns -1 when the code is not 356 or 357, else what the command's function said, or 0 */
int kon_rmPluginHost(kon_rmPlugins_t *plugins, int code, const char *text);
/* the commands that were not in the table, in the order they first came, 1 and the name and how often, or 0 past the last */
int kon_rmPluginMissed(const kon_rmPlugins_t *plugins, int index, const char **name, int *count);
#ifdef __cplusplus
}
#endif
#endif
|