3

This:

debug.getmetatable("").__index = function (s, i) return s:sub(i, i) end

and this:

debug.getmetatable("").__index = _proc_lua_read

does not work.

1 Answer 1

5

Try

debug.getmetatable("").__index = function (s, i) return string.sub(s,i,i) end

Note that by redefining __index for strings in that way, you lose the ability to call methods on strings: note how the code does not call s:sub. For a better solution that avoids that, see http://lua-users.org/lists/lua-l/2007-11/msg00619.html . Or set __call instead:

getmetatable("").__call = string.sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.