2

I am using Lua (5.2.1), in a library, called from C++.

For example from C++ I call the function OnHear and pass the heard text.

In my Lua files, however, I have examined something weird:

function OnHear(_Text)
    txt = _Text;
    txt = string.lower(txt); -- comment this line to make the code below run
-- other code
end

It does not work; "other code" runs fine when the line with lower is commented, but not if it is being executed.

function OnHear(_Text)
    txt = string.lower(_Text);
-- other code 
end

same problem...

I also found out, that the same problem (code afterwards not being executed) occurs when I call for instance string.len(txt) or anything like that...

I have no idea what could cause my problem and Googling/searching Stackkoverflow did not help me, sadly...

Thanks for any reply in advance!

1 Answer 1

3

Have you opened the Lua standard libraries from C++?

void luaL_openlibs (lua_State *L);

Opens all standard Lua libraries into the given state.

From http://www.lua.org/manual/5.2/manual.html#luaL_openlibs.

EDIT

The lua binary opens the libraries by default, but sometimes, when the interpreter is embedded, the libraries can be superfluous.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, this fixed the problem :) I did not know about this function yet...(I feel dumb^^)

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.