Created
February 26, 2023 04:58
-
-
Save leetrout/ef6cd27fe6661c279ac30ce61faae5bb to your computer and use it in GitHub Desktop.
Minecraft WorldEdit debug script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Small helper script to debug via printing in WorldEdit CraftScript. | |
* Save this file as debug.js in your WorldEdit config folder: | |
* e.g. config/worldedit/craftscript/debug.js | |
* | |
* Use in the console: | |
* /cs debug | |
* /cs debug player | |
* | |
* With no arguments this script will print all globals. | |
* | |
* With one argument this script will print the properties | |
* of the object. | |
*/ | |
var global = this; | |
function allProps(someObj) { | |
Object.getOwnPropertyNames(someObj) | |
.sort() | |
.map((x) => context.print(x)); | |
} | |
function localProps(someObj) { | |
Object.keys(someObj) | |
.sort() | |
.map((x) => context.print(x)); | |
} | |
function main() { | |
context.print(""); | |
context.print("Debug script for CraftScript"); | |
context.print("--------------------------------"); | |
if (argv.length > 1) { | |
var x = argv[1]; | |
var obj = global[x]; | |
context.print("Inspecting " + x + "(" + obj + ")"); | |
localProps(obj); | |
} else { | |
allProps(global); | |
} | |
context.print("--------------------------------"); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment