I'm trying to make a function with the command bar that encodes characters into byte and then implements the backslash so I can copy it for use in a script. For example:
Encode("ab")
would print "\97\98"
I almost had when I figured out that doing
print("\\98")
would print "\98", but I implement that into the function, and it calls an error for an unfinished string. Here's the code I tried:
function Encode(str) final = [[]] sub = "" for i = 1, string.len(str) do sub = "\"..string.sub(str, i, i) final = final..sub end print(final) end
Is there a way to make a function that does what I want?

3 comments
What line is the error, it only shows one on here.
It's a command bar script. The error is on the second line of the code block where it says "sub = ""..string.sub.. etc, etc.
Another problem? Tell me it.