Minecraft Versions: [1.16.5, 1.12.2]
Official repo to get started with CustomNPC Scripting in Visual Studio Code.
It contains several example scripts as well as Intellisense(autocompletion) for CustomNPCs.
NOTE: This repo is still WIP. Snippets and Typings are still in the making. Intellisense for 1.12.2 is done! Check it out in the 1.12.2 branch! (1.16.5 coming soon)
Visual Studio Code is one of many editors to use in scripting/programming. We use it for its ability to make scripting really easy.
Make sure to download VSCode from its official website.
CustomNPCs allows you to choose your own language to script in. You only have to download a specific .jar file for your chosen language. Click here for info about enabling scripting
This repo contains only javascript examples for now so we assume you downloaded nashorn.jar
.
If you are running CustomNPCs on a server, then only the server needs nashorn.jar
.
If you are making a modpack for singleplayer or self-host use you'll need to include nashorn.jar
in your modpack.
This can be problematic if you have a CurseForge modpack, but is easily solved because someone uploaded nashorn.jar
to CurseForge
Download this repository and open it up in VSCode to get started! Create some directories. Organize the example files how you want it.
Do NOT remove jsconfig.json
and .vscode
or you'll lose your autocompletion feature.
Decide what type of script you want to make. You can choose from:
- NPC Script (Scripts that are executed by NPCs)
- Item Script (Scripts that are executed by scripted items)
- Block Script (Scripts that are executed by scripted blocks)
- Player Script (Scripts that are executed by every player)
TODO: add explanation on in-game steps to run scripts
This repo contains some example scripts provided by people from the discord server. Some comments might be added/changed inside example scripts, but are kept as original as possible.
This list is sorted by simplest above.
tempdata.js
byDaot
storeddata.js
byDaot
retreat_weapon.js
byRunon
lockable_door.js
byAnnikenYT
transporters_fee.js
byXelerax
TODO: add more examples TODO: test examples
Summary of all links scattered in this document plus a few more.
Docs
CustomNPCs 1.16.5 Documentation
Downloads
VSCode
Learn CustomNPCs & JavaScript
W3Schools
Tutorialspoint
Eloquentjavascript
FreeCodeCamp
Daot's YouTube channel
Yellow768's CNPC playlist
Other
Nashorn on CurseForge
For your modpack
Copy-Paste mod (This copies files to every world and keeps it updated, handy to keep scripts updated for your singleplayer based modpacks!)
This repo contains some extra handy files to enhance your scripting experience.
TODO: Add explanation on snippets, what to type, etc
TODO: Add explanation on autocomplete, how it works, etc
Make sure your jsconfig.json
and .vscode
still exists within the root of your opened VSCode project.
This is required for VSCode to know what we are programming. It tells VSCode stuff about the code.
Need some scripting help or want to share your creation? Go ahead and join our official CNPC Scripting discord server.
For non-scripting related questions, join the official CustomNPC Discord