Console API
Console API
When the game is running, GP-Next exposes a global object:
window.gpNextYou can call it directly from the developer console.
Tips
If you are not sure which commands are available, start with:
gpNext.help()Before You Use It
- the game has finished loading
- GP-Next has initialized successfully
- you have opened the developer console
If you want to export original Features, Props, or language JSON before writing a patch, start with Source Data.
Panel
gpNext.toggle()
Shows or hides the GP-Next panel.
No parameters.
Example
gpNext.toggle()gpNext.show()
Shows the panel.
gpNext.hide()
Hides the panel.
gpNext.help()
Prints command help in the console.
Patches and Status
gpNext.init()
Runs the patch loading process again.
Return Value
Usually returns the current patch loading result.
gpNext.reload()
Reads patch files from disk again and reapplies them.
This is one of the most commonly used commands.
Example
await gpNext.reload()gpNext.status()
Shows the current patcher status.
Main Return Fields
loaded: list of loaded typesskipped: types that were skippederrors: error listpacks: currently detected datapacksdisabledPacks: disabled datapackssingleFile: single-file patch informationeditsPack: manual edits pack informationeditsCount: number of manual editsextraLanguages: currently registered extra languagesplantRegistry: debug information for the dynamic plant registry
Example
const status = gpNext.status()
console.log(status.packs)
console.log(status.errors)Data Editing
gpNext.setObjectsData(type, alias, key, value)
Edits a single field in an Objects-type entry.
Parameters
type: object type name, for examplePlantPropsalias: primary alias of the target entry, for examplepeashooterkey: field name to editvalue: new value
Example
gpNext.setObjectsData('PlantProps', 'peashooter', 'SunCost', 50)gpNext.setObjectsData(type, alias, patchObject)
Merges an object into the target entry's objdata.
Parameters
type: object type namealias: primary alias of the target entrypatchObject: object to merge into the entry
Example
gpNext.setObjectsData('PlantProps', 'peashooter', {
SunCost: 50,
Cooldown: 2
})Warning
This is a runtime edit. It is good for debugging and quick verification, but it does not automatically create a proper datapack for you.
Export and Restore
gpNext.exportJson(type, useOriginal = false, autoDownload = true)
Exports a JSON type.
Parameters
type: type name, for examplePlantFeaturesuseOriginal:trueexports original data,falseexports current runtime dataautoDownload:trueopens a save dialog,falseprints the result to the console
Example
await gpNext.exportJson('PlantProps')
await gpNext.exportJson('PlantProps', true)
await gpNext.exportJson('PlantProps', false, false)gpNext.exportLang(useOriginal = false, autoDownload = true)
Exports the current language table MultiLanguage.lyrics.
Good Uses
- checking whether a language pack has taken effect
- comparing the current extended language result
- exporting the original language table for comparison
Example
await gpNext.exportLang()
await gpNext.exportLang(true)gpNext.restoreOriginal(type)
Restores one type back to the original data.
Example
gpNext.restoreOriginal('PlantFeatures')gpNext.restoreAll()
Restores all backed-up types.
gpNext.listOrigins()
Lists all types that currently have original backups.
gpNext.hasOrigin(type)
Checks whether a type has an original backup.
Game
gpNext.setFrameRate(fps)
Sets the game's frame rate.
Parameters
fps: number such as30or60
Example
gpNext.setFrameRate(60)gpNext.setGameSpeed(multiplier)
Directly changes the underlying time scale.
Parameters
multiplier: speed value such as1or1.5
Example
gpNext.setGameSpeed(1)
gpNext.setGameSpeed(1.5)Warning
This command exists, but it uses the low-level _timeScale path and is not as safe as the native 1x / 1.5x options in the Trainer page. In most cases it is better to switch game speed from the UI.
Cheats
gpNext.cheats.setSun(value)
Directly sets the current sun amount.
Example
gpNext.cheats.setSun(9999)gpNext.cheats.addSun(value = 1000)
Adds sun.
Example
gpNext.cheats.addSun()
gpNext.cheats.addSun(500)gpNext.cheats.winLevel()
Triggers an instant win for the current level.
Warning
In some testing or sandbox scenes, this is better treated as a temporary shortcut than as part of a stable workflow.
Debug
gpNext.debug.getPlantRegistry()
Shows debug information for the dynamic plant registry.
Useful For
- adding new plants
- cloning plants
- troubleshooting plant identity mapping
Example
const info = gpNext.debug.getPlantRegistry()
console.log(info)Other
gpNext.version
Current GP-Next version.
Example
gpNext.versiongpNext.debug
This is a debug namespace, not just a boolean switch.
The most commonly used method right now is:
gpNext.debug.getPlantRegistry()Examples
Reload patches and inspect status
await gpNext.reload()
console.log(gpNext.status())Quickly verify plant values
gpNext.setObjectsData('PlantProps', 'peashooter', {
SunCost: 50,
Cooldown: 2
})Export current data to the console
await gpNext.exportJson('PlantProps', false, false)Export the original language table
await gpNext.exportLang(true)