I'm trying to add a function to the table string.
function string.bytes(s_str) -- errors assert(type("") == type(s_str), "bad argument #1 to 'string.bytes' (string expected, got " .. type(s_str) .. ")") return tostring(s:gsub(".", function(c) return ("\\" .. c:byte()) or c or "" end)) end
How can I unlock string table?
The solution is a one liner. I believe that metatables are the quickest way of doing this. Place this line at the top of script (or above function)
local string = setmetatable({}, {__index = string})