1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-11 04:19:58 +00:00
CC-Tweaked/doc/reference/breaking_changes.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
4.3 KiB
Markdown
Raw Normal View History

---
module: [kind=reference] breaking_changes
---
<!--
SPDX-FileCopyrightText: 2019 The CC: Tweaked Developers
SPDX-License-Identifier: MPL-2.0
-->
# Incompatibilities between versions
CC: Tweaked tries to remain as compatible between versions as possible, meaning most programs written for older version
of the mod should run fine on later versions.
> [External peripherals][!WARNING]
>
> While CC: Tweaked is relatively stable across versions, this may not be true for other mods which add their own
> peripherals. Older programs which interact with external blocks may not work on newer versions of the game.
However, some changes to the underlying game, or CC: Tweaked's own internals may break some programs. This page serves
as documentation for breaking changes and "gotchas" one should look out for between versions.
## CC: Tweaked 1.109.0 {#cct-1.109}
- Update to Lua 5.2:
- Support for Lua 5.0's pseudo-argument `arg` has been removed. You should always use `...` for varargs.
- Environments are no longer baked into the runtime, and instead use the `_ENV` local or upvalue. `getfenv`/`setfenv`
now only work on Lua functions with an `_ENV` upvalue. `getfenv` will return the global environment when called
with other functions, and `setfenv` will have no effect.
- `load`/`loadstring` defaults to using the global environment (`_G`) rather than the current coroutine's
environment.
- Support for dumping functions (`string.dump`) and loading binary chunks has been removed.
Always use raw bytes in file handles Historically CC has supported two modes when working with file handles (and HTTP requests): - Text mode, which reads/write using UTF-8. - Binary mode, which reads/writes the raw bytes. However, this can be confusing at times. CC/Lua doesn't actually support unicode, so any characters beyond the 0.255 range were replaced with '?'. This meant that most of the time you were better off just using binary mode. This commit unifies text and binary mode - we now /always/ read the raw bytes of the file, rather than converting to/from UTF-8. Binary mode now only specifies whether handle.read() returns a number (and .write(123) writes a byte rather than coercing to a string). - Refactor the entire handle hierarchy. We now have an AbstractMount base class, which has the concrete implementation of all methods. The public-facing classes then re-export these methods by annotating them with @LuaFunction. These implementations are based on the Binary{Readable,Writable}Handle classes. The Encoded{..}Handle versions are now entirely removed. - As we no longer need to use BufferedReader/BufferedWriter, we can remove quite a lot of logic in Filesystem to handle wrapping closeable objects. - Add a new WritableMount.openFile method, which generalises openForWrite/openForAppend to accept OpenOptions. This allows us to support update mode (r+, w+) in fs.open. - fs.open now uses the new handle types, and supports update (r+, w+) mode. - http.request now uses the new readable handle type. We no longer encode the request body to UTF-8, nor decode the response from UTF-8. - Websockets now return text frame's contents directly, rather than converting it from UTF-8. Sending text frames now attempts to treat the passed string as UTF-8, rather than treating it as latin1.
2023-11-08 19:37:10 +00:00
- File handles, HTTP requests and websockets now always use the original bytes rather than encoding/decoding to UTF-8.
## Minecraft 1.13 {#mc-1.13}
- The "key code" for [`key`] and [`key_up`] events has changed, due to Minecraft updating to LWJGL 3. Make sure you're
using the constants provided by the [`keys`] API, rather than hard-coding numerical values.
Related to this change, the numpad enter key now has a different key code to the enter key. You may need to adjust
your programs to handle both. (Note, the `keys.numpadEnter` constant was defined in pre-1.13 versions of CC, but the
`keys.enter` constant was queued when the key was pressed)
- Minecraft 1.13 removed the concept of item damage and block metadata (see ["The Flattening"][flattening]). As a
result `turtle.inspect` no longer provides block metadata, and `turtle.getItemDetail` no longer provides damage.
- Block states (`turtle.inspect().state`) should provide all the same information as block metadata, but in a much
more understandable format.
- Item and block names now represent a unique item type. For instance, wool is split into 16 separate items
(`minecraft:white_wool`, etc...) rather than a single `minecraft:wool` with each meta/damage value specifying the
colour.
- Custom ROMs are now provided using data packs rather than resource packs. This should mostly be a matter of renaming
the "assets" folder to "data", and placing it in "datapacks", but there are a couple of other gotchas to look out
for:
- Data packs [impose some restrictions on file names][legal_data_pack]. As a result, your programs and directories
must all be lower case.
- Due to how data packs are read by CC: Tweaked, you may need to use the `/reload` command to see changes to your
pack show up on the computer.
See [the example datapack][datapack-example] for how to get started.
- Turtles can now be waterlogged and move "through" water sources rather than breaking them.
## CC: Tweaked 1.88.0 {#cc-1.88}
- Unlabelled computers and turtles now keep their ID when broken, meaning that unlabelled computers/items do not stack.
## ComputerCraft 1.80pr1 {#cc-1.80}
- Programs run via `shell.run` are now started in their own isolated environment. This means globals set by programs
will not be accessible outside of this program.
- Programs containing `/` are looked up in the current directory and are no longer looked up on the path. For instance,
you can no longer type `turtle/excavate` to run `/rom/programs/turtle/excavate.lua`.
[flattening]: https://minecraft.wiki.com/w/Java_Edition_1.13/Flattening
[legal_data_pack]: https://minecraft.gamepedia.com/Tutorials/Creating_a_data_pack#Legal_characters
[datapack-example]: https://github.com/cc-tweaked/datapack-example "An example datapack for CC: Tweaked"