-
Notifications
You must be signed in to change notification settings - Fork 0
Create a Module
Hawkmax edited this page Oct 10, 2025
·
3 revisions
Since RichJSON is very abstract and has commands that can be basicly seen as functions, we implemented the possiblity to extend RichJSON with custom modules. In fact you can write your own custom modules for your game specific usecases in order to make your data files a better fit.
It's quite simple, first you have to register a module like:
rich_json_module_register(
new RichJsonModule("my_module")
.add_command(...)
.add_late_apply(...)
);Notice both functions add_command() and add_late_apply():
Use add_command() in order to add a normal command that is going to be resolved when the JSON file is read in.
new RichJsonModule("my_module")
.add_command("ilog", function(_cryptkey, _add_to_cache, _root, _current, _command, _member, _address, _name) {
ilog(_member);
return _member;
})
;Use add_late_apply() in order to add a late apply command that is going to be resolved at Late Applying.
new RichJsonModule("my_module")
.add_late_apply("wlog", function(_cryptkey, _add_to_cache, _root, _current, _command, _member, _address, _name) {
wlog(_member);
return _member;
})
;function(_cryptkey, _add_to_cache, _root, _current, _command, _member, _address, _name) {| Parameter | Description |
|---|---|
| _cryptkey | This is primarly used by the raptor file functions. |
| _add_to_cache | This is primarly used by the raptor file functions. |
| _root | The current root struct, could be a file, game object, command result. |
| _current | The current struct or array that is currently resolved. |
| _member | The current member's value (string or struct) that is currently resolved. |
| _address | The current member's address that is used by RichJSON. |
| _name | The current member's name. |
There a two ways for including a module in RichJSON:
/// @func rich_json_module_include(_name)
/// @desc If a module with the specified name exists, it is going to be included
function rich_json_module_include(_name) {// With this macro you can auto include your own modules
// and exclude the built-in raptor modules. Just add them to the array.
#macro RICH_JSON_AUTO_INCLUDED_MODULES global.__rich_json_auto_included_modules
RICH_JSON_AUTO_INCLUDED_MODULES = [ "raptor", "raptor_ui" ]/// @func rich_json_module_register(_module)
/// @desc If a module with the specified name already exists, it is overwritten
function rich_json_module_register(_module) {/// @func rich_json_module_unregister(_name)
/// @desc If a module with the specified name exists, it is getting unregistered
function rich_json_module_unregister(_name) {/// @func rich_json_module_include(_name)
/// @desc If a module with the specified name exists, it is going to be included
function rich_json_module_include(_name) {/// @func rich_json_module_exclude(_name)
/// @desc Excludes a module. If the specified module does not exist, this is silently ignored
function rich_json_module_exclude(_name) {/// @func rich_json_module_exists(_name)
/// @desc Query existance of a module. Returns bool.
function rich_json_module_exists(_name) {Author’s Recommendation: next read Keep Key Command
Back to Repo ● Wiki Home
Copyright © coldrock.games