Lua scripts in lower case lines

I added a Lua script to my C # application using DynamicLua libary and it works very well. I would like to realize that you get the current line that is running (as in Visual Studio), and highlight it.

I am currently doing this:

   public static void RunLua(string LuaToExecute)
    {
        dynamic lua = new DynamicLua.DynamicLua();

        string[] lua_s_split = LuaToExecute.Split('\n');
        int counter = 0;
        foreach (string line in lua_s_split)
        {
            // highlight current line in editor
            HighlightLine(counter + 1);

            //execute current line 
            lua(line);
            counter++;
        }
    }

This works fine with my Lua code like

move(20, 19)
sleep(1000)
move(5, 19)

but I can not execute only one string expression. Like my related function move(). But I would also like to use multi-line expressions such as functions and loops. If the text editor contains:

function test()
    return  "Hallo Welt"
end

lua(line)will throw an exception because only the first line is passed function test(), and the interpreter is missing the final operator.

? , , ... , ? ? ?

, .

+4
2

, , ( Visual Studio), .

, Lua script . script Lua , :

Lua:
Lua: debug.sethook

+4

[EDIT] LUA, . , , , . , . , . [/EDIT]

/ LUA.

, , .

var myCommand = new StringBuilder()

... myCommand.Append(line) ...

foreach (string line in lua_s_split)
    {
        // highlight current line in editor
        HighlightLine(counter + 1);

        //execute current line 
        If(NeedsToExecute(istrue))
        {
            lua(myCommand.ToString());
            counter++;
        }
        else{myCommand.appendline(line)
    }
+2

Source: https://habr.com/ru/post/1545421/


All Articles