-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Scripts
This section guides you through the process of creating, downloading, and injecting custom scripts for the Minecraft Bot Panel (MCBP). Custom scripts allow you to extend and personalize the behavior of your bots.
You can download custom scripts from the official MCBP community on Discord. Join the server to find a variety of scripts shared by other users.
Discord Link: Join Our Discord
Once you have created or downloaded a custom script, you need to inject it into the MCBP.
-
Locate the MCBP Directory:
-
If installed via setup
.exe
:- Navigate to
%appdata% => Local => minecraft_bot_panel
- Navigate to
-
If installed via zip file:
- Open the directory where you extracted the files.
- Navigate to
.\resources\app.asar.unpacked\custom\scripts
.
-
If installed via setup
-
Place the Script:
- Move your
.js
script file into thescripts
directory located in the paths described above.
- Move your
-
Reload or Restart MCBP:
- After placing your script, restart the Minecraft Bot Panel. Your script should now appear in the MCBP interface, ready to be used.
To create a custom script, you'll need to make a .js
file with the following template:
let info = {
name: "<name>", // Replace <name> with the script's name | NOTE: Using spaces in names may result in many bugs
default: { interval: 200 }, // Default settings for the script
options: [
// Add options here, e.g., { type: 'input', label: 'Block ID' }
],
};
function script(bot, log, clearLog, getOption, scriptRepeater) {
// Your script logic goes here
}
module.exports = {
info,
script,
};
In order to get the value of an option declared in let info
use:
getOption("<option_id>", info.name) // Replace <option_id> with the actual option's ID
.then((value)=>{
console.log(value) // Example
})
As you can see getOption
returns a Promise
.
To loop your script if user selected it:
let info = {
name: "ScriptExample",
default: { interval: 200 },
options: [
{
type: "checkbox",
label: "Repeat",
id: "repeat",
},
],
};
It's important to set the type to "checkbox" and id to "repeat"
function script(bot, log, clearLog, getOption, scriptRepeater) {
getOption("repeat", info.name).then((r) => {
function yourFunction() {
// Your code
}
if (r === "on") {
scriptRepeater(yourFunction, info.default.interval).then(() => { // Feel free to change info.default.interval into a number or value in let info
return;
});
} else yourFunction();
});
}
log(text)
"logs" the text you've provided into the MCBP's logs tab.
clearLog(text)
clears every already logged message that include provided text.