JavaScript Mods
CampAPI's JS system is built for practical modding: one manifest, one entry file, then optional extra modules.
Folder layout
text
{CampAPIRootFolder}/scripts/
ExampleMod/
manifest.json
scripts/
index.js
utils.jsManifest fields
The loader reads these fields from manifest.json:
name— mod display nameauthor— author nameversion— version stringnamespace— namespace used for@namespace/...importsexport— marks the mod as importable by namespaceentryormain— the entry file insidescripts/
Example:
json
{
"name": "Example Mod",
"author": "Alvin",
"version": "1.0.0",
"namespace": "example",
"export": true,
"entry": "index.js"
}What JS mods get out of the box
The runtime gives you a few ready-to-use tools:
console.log,console.info,console.warn,console.error,console.debugstdandos- Node-style helpers such as
node:process,node:timers,node:events,node:path,node:util,node:buffer,node:fs, andnode:os internal:modfor mod info lookupinternal:networkforfetchinternal:moddingfor signature scanning
Example entry file
js
import { getModInfoByName } from 'internal:mod'
import { sigscan } from 'internal:modding'
import { fetch } from 'internal:network'
console.log('mod info:', getModInfoByName('Example Mod'))
const addr = sigscan('libminecraftpe.so', '48 8B ?? ??')
console.log('sigscan:', addr)
const response = fetch('https://example.com/api/version', {
method: 'GET',
timeout: 2
})
console.log(response.status, response.ok)
console.log(response.text())Importing shared files from another exported mod
If a mod is exported, another mod can import its files with @namespace/path.
js
import { helper } from '@example/utils.js'That is useful for shared utilities, constants, or reusable bootstraps.
Practical notes
- The entry file must live under the mod's
scripts/folder. entryfalls back tomain.- If neither is present, the loader uses
index.js.