
In the original implementation of our prettier runtime errors (#1320), we wrapped the errors thrown within parallel functions into an exception object. This means the call-stack is available to the catching-code, and so is able to report a pretty exception message. Unfortunately, this was a breaking change, and so we had to roll that back. Some people were pcalling the parallel function, and matching on the result of the error. This is a second attempt at this, using a technique I've affectionately dubbed "magic throws". The parallel API is now aware of whether it is being pcalled or not, and thus able to decide whether to wrap the error into an exception or not: - Add a new `cc.internal.tiny_require` module. This is a tiny reimplementation of require, for use in our global APIs. - Add a new (global, in the debug registry) `cc_try_barrier` function. This acts as a marker function, and is used to store additional information about the current coroutine. Currently this stores the parent coroutine (used to walk the full call stack) and a cache of whether any `pcall`-like function is on the stack. Both `parallel` and `cc.internal.exception.try` add this function to the root of the call stack. - When an error occurs within `parallel`, we walk up the call stack, using `cc_try_barrier` to traverse up the parent coroutine's stack too. If we do not find any `pcall`-like functions, then we know the error is never intercepted by user code, and so its safe to throw a full exception.

CC: Tweaked is a mod for Minecraft which adds programmable computers, turtles and more to the game. A fork of the much-beloved ComputerCraft, it continues its legacy with improved performance and stability, along with a wealth of new features.
CC: Tweaked can be installed from Modrinth. It runs on both Minecraft Forge and Fabric.
Contributing
Any contribution is welcome, be that using the mod, reporting bugs or contributing code. If you want to get started developing the mod, check out the instructions here.
Community
If you need help getting started with CC: Tweaked, want to show off your latest project, or just want to chat about
ComputerCraft, do check out our GitHub discussions page! There's also a fairly populated,
albeit quiet IRC channel on EsperNet, if that's more your cup of tea. You can join #computercraft
through your
desktop client, or online using KiwiIRC.
We also host fairly comprehensive documentation at tweaked.cc.
Using
CC: Tweaked is hosted on my maven repo, and so is relatively simple to depend on. You may wish to add a soft (or hard)
dependency in your mods.toml
file, with the appropriate version bounds, to ensure that API functionality you depend
on is present.
repositories {
maven {
url "https://maven.squiddev.cc"
content {
includeGroup("cc.tweaked")
}
}
}
dependencies {
// Vanilla (i.e. for multi-loader systems)
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-common-api:$cctVersion")
// Forge Gradle
compileOnly("cc.tweaked:cc-tweaked-$mcVersion-core-api:$cctVersion")
compileOnly(fg.deobf("cc.tweaked:cc-tweaked-$mcVersion-forge-api:$cctVersion"))
runtimeOnly(fg.deobf("cc.tweaked:cc-tweaked-$mcVersion-forge:$cctVersion"))
// Fabric Loom
modCompileOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric-api:$cctVersion")
modRuntimeOnly("cc.tweaked:cc-tweaked-$mcVersion-fabric:$cctVersion")
}
You should also be careful to only use classes within the dan200.computercraft.api
package. Non-API classes are
subject to change at any point. If you depend on functionality outside the API (or need to mixin to CC:T), please file
an issue to let me know!
We bundle the API sources with the jar, so documentation should be easily viewable within your editor. Alternatively, the generated documentation can be browsed online.