CC: Tweaked

CC: Tweaked

42M Downloads

Update Cobalt to 0.5.1

SquidDev opened this issue ยท 1 comments

commented

With the help of Abigail, I've been making some updates to Cobalt to bring it more in line with PUC Lua, and incorporate some versions of Lua 5.2/5.3.

Obviously it'd be nice to update CC:T to use these features. However, there's a couple of things which will need testing to ensure they do not break existing programs too badly.

You can see the list of changes since the last CC:T update, but a brief summary of things which may make a noticeable difference:

  • The __len metamethod may now be used by tables.

  • Strings now accept hexadecimal, unicode and the zap (\z) escape code. Please make sure you're only using valid escape codes - this can be done by chucking your code into illuaminate, or running it through Lua 5.3.

  • Java functions are no longer tail called. This means that return error("bad argument") will no longer lay blame at the calling function. This should be replaced with error("bad argument", 2), or use the cc.expect library.

Some other niceties which won't break anything, but worth pointing out.

  • Add Lua 5.3's utf8 library.
  • math.log also accepts a "base" argument (e.g. math.log(123, 2) is log2(123)).
  • Parser error messages now include the token where the error occurred.
  • table.unpack now uses __len and __index metamethods.
commented

Slight issue with the errors in tail calls, the one I noticed was in the peripheral API. Example:

local mon = peripheral.find("monitor")
mon.setTextColour(nil)

Claims the error is in peripheral.lua:

https://github.com/SquidDev-CC/CC-Tweaked/blob/0ffd5fcf85c58cf4508ab2c69cd1339cd4c5f89d/src/main/resources/assets/computercraft/lua/rom/apis/peripheral.lua#L70