"cc.strings".wrap() seems to not return a string
XLuma opened this issue ยท 2 comments
Useful information to include:
- Minecraft version
- CC: Tweaked version
- Logs: These will be located in the
logs/
directory of your Minecraft instance. Please upload them as a gist or directly into this editor. - Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed.
MC ver: 1.16.4
CC:Tweaked: Latest
(no external log)
I am trying to parse a very long string with cc.strings.require so the wrapped printer can print all parts of the string rather than getting to the end of the line and stopping there. However, when trying to wrap() a variable containing a string, and trying to print the result, the program crashes with "Tried to concatenate global/local "string" (a table value)"
The input is a read(). Sample code would look like
local string = require "cc.string".wrap(read(),10)
Maybe I am doing it wrong, but I am taking this from the documentation (and is also labeled as a use to wrap a string before sending to a printer)
string
is a standard API name; using it as a variable name can cause unintended behavior. It looks like you're defining a string
variable in one place, but then that gets lost in some way, and when further code tries to print it it prints the string
API instead of your string
variable. I'd recommend using a different name, such as str
.
This is expected behaviour - cc.strings.wrap
returns a list of lines, rather than a single string.
I've updated the docs to hopefully make that more obvious. If it's still not clear, do say - I'm not very good at actually explaining how things work :/.