Installing carpet scripts in your world - gnembon/fabric-carpet GitHub Wiki

Getting apps

The Scarpet repo

Before you install any apps in your world(s), you need to actually have apps. You can check the Scarpet repository for apps which you might be interested in. If you know a little bit about Scarpet the apps in the repo are pretty self-explanatory, some of them are even featured in videos showcasing things you can do with Scarpet where gnembon explains how his apps work.

Simple Loading

For most apps and in default settings, if you plop them into the world's scripts folder, along with their optional data files, they will just load automatically (see File shenanigans below)

Advanced Loading Options

If you want to customize how apps are loaded, there are several things you can do. First, if you don't want an app to load automatically when world starts, you can do that by editing (creating) apps config by setting its 'stay_loaded' option to false, or globally in the world by setting /carpet scriptAutoload false. This is pretty straightforward to do; at the beginning of your app, add the following line of code, and app will be unloaded right after starts with the world:

__config() -> {'stay_loaded' -> false};

Now the apps with that __config() modified will not stay loaded, meaning we have to manually load them every time we enter the world or start the server. For the details on this check the docs or watch the bit of this video where gnembon explains __config() too (note that the initial behaviours of 'stay_loaded' and 'scriptsAutoload' were reversed).

In case you want to share the app across multiple world files, you can place it in the shared mod config space in .minecraft/config/carpet/scripts. These apps will also not be loaded by default, and you need to load them manually. Note that if the app requires some data to be provided, all of these need to stay in the worlds scripts folder - shared config spaces is only to provide apps code between for worlds on a singleplayer. Worlds do not share the data.

To manually load an app (in case its autoloading is disabled, or autoloading is disabled in the carpet, or the app is in the shared config space), you can load them individually by typing /script load <app name> and replace <app name> with the name of the .sc file app you wanna load, and voila! Beware, however, that <app name> can't contain any spaces in it. Due to how the minecraft command system works, separating things in the command line with spaces makes the game think that each part separated by strings is a different argument. So if your app's name is 'my app', when you type /script load my app the game will interpret this as /script load my with an extra argument app, and will give you an error. Loading your app even works if you edit the app; after you save the changes, you can just type the command /script load <app name> again and your changes will be visible. Alternatively, you can just type `/reload' to reload all apps, datapacks and vanilla resources. The only problem is, you'll have to do this every time you enter the world/restart your server.

Writing your own stuff

While you can just grab ready apps from the scarpet app store and plop them directly in your world, you may decide to first tweak the existing apps to your needs, or maybe write something on your own - great choice. Currently there is Scarpet editor support for Notepad++, Intellij IDEA keyword sets, and Vscode Autocompletion, but if more are added you can find them all here; go ahead and grab the one specific to your favourite editor and get writing!

You have all the docs here.

File shenanigans

Important note: your file names can't have spaces in them, if they do you won't be able to load them into your worlds. The reason why is explained later.

1. Files must have a .sc file extension

If you've been editing plain text files (.txt) or other text file formats (.doc, .docx, .rtf...), it's time to switch your file extension to .sc so that you can use those apps in your worlds. If you've been editing .sc files already, you can skip this step. Go ahead and open the folder where you put all your Scarpet apps; mine are under %appdata%/_fabric/Scarpet. Now go ahead and change the file extension of the app you want to use in your worlds to .sc:

extchange

2. Create a 'scripts' folder in your world if it doesn't exist

If your game directory for Carpet mod worlds is the same as your vanilla directory, your worlds will be in %appdata%/.minecraft/saves, but if your modded directory is different from your vanilla directory you'll have to go to that directory, e.g. modded_mc/saves; in my case, my carpet worlds are under %appdata%/_fabric/saves. Go ahead and open the world folder you want to put your apps in. Create a new folder inside called scripts; I'll be doing it in my 'New World' world:

scriptsfolder

3. Put your scarpet apps in the 'scripts' folder

Open your folder with all the apps you've been writing, copy the ones you want to use in your world, and paste them in that world's scripts folder:

image

And... that's it for the file shenanigans. Now we need to configure stuff within the apps and the world itself in order for everything to work how we want it to work.

4. Making some apps available in all singleplayer worlds

If you want to be able to load some apps from any of your singleplayer worlds, you can also place them in %appdata%\.minecraft\config\carpet\scripts. Those won't be autoloaded, but you can still load and unload them from anywhere using /script load <app> command. If you try to load an app that is in both scripts folders, Carpet will always prefer the one in the world's folder than the one in the global folder. Also if the app comes with data files it needs to function - these need to be added to the world's scripts folder and not stored in the config location.

⚠️ **GitHub.com Fallback** ⚠️