CC: Tweaked

CC: Tweaked

57M Downloads

crash by term.blit()

luochen1990 opened this issue ยท 5 comments

commented

Useful information to include:

  • Minecraft version: 1.15.2
  • CC: Tweaked version: cc-tweaked-1.15.2-1.86.2
  • Detailed reproduction steps: term.blit("abc", "red", "whi")

I don't know how to use term.blit(), I have read the api document but there is no details about what the second and third argument should be, so I tried myself, and find that this API will crash the game.

commented

The second and third arguments show each character's text and background colour respectively - that's why they have to be the same length as your string. You have to use the colour's hexadecimal code (0-9a-f), which you can find on the new wiki: https://wiki.computercraft.cc/Colours_API

For example, to blit the text "ABC" with red text and a white background, you'd use the code e for red and 0 for white:

term.blit("abc", "eee", "000")

The blog function allows you to specify a different colour for each character in an efficient way. For example, to draw rainbow text on a black background:

term.blit("Rainbow", "e145ba2", "fffffff")

Notice how every character in the second string is different - these are the text colours and each character corresponds to a different colour code that can be found in the table I linked. Likewise, every character is the same in the third string, because all the characters are on a black background.

The reason you are crashing is because r, w, h and i are not valid colour codes. However, this should just print an error/render nothing, not crash the entire game - this is likely a 1.15.2 bug.

commented

Also,

I have read the api document but there is no details about what the second and third argument should be

And there are three examples on there.

commented

@Lemmmy Thanks, thats very helpful, I forget to click inside the detail page...

But still, I think this is a bug, since improper call of API should not crash the game...

commented

Definitely still a bug, yeah. It only crashes with invalid characters in the colour strings (g-z), right? A normal blit usage like term.blit("a", "0", "f") works correctly? If so, could you provide the crash logs?

commented

I'm fairly sure this will never crash the game - we catch any errors within computers, so problems should never propagate elsewhere.

As Lem says, if you've still got the crash logs kicking around (or are able to reproduce again), please upload them and I'll reopen this issue!