pascal - Syntax error when loading lua script -


im trying use lua in application, when trying load script using lua_loadbuffer, error message.

luacontext := lua_newstate(@alloc, nil);   try     lual_openlibs(luacontext);     s := 'print("hi")';     lua_register(luacontext, 'print', @print_func);       if lual_loadbuffer(luacontext, pchar(s), length(s), pchar('sample1')) <> 0     begin       raise exception.create(lua_tostring(luacontext, -1));  //<- following error message here:  [string "sample1"]:1: syntax error     end;     if lua_pcall(luacontext, 0, 0, 0) <> 0       exception.create('');   except       debugln('error: ' + lua_tostring(luacontext, -1));   end; 

afaik lua code valid, right? "syntax error" isn't descriptive, , me not having expierience lua, don't know mistakes.

lua not work utf-16 strings.
ensure data encoded 1-byte codepage, use ansistring , pansichar instead of string , pchar.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -