1

I have some Lua code in C# as a string and I'd like to check if it's valid (any syntax errors, that sort of thing).

How can I go about doing that in a quick and efficient manner?

edit: the other suggested duplicate question does not simply check for valid syntax but valid code, luaL_loadstirng fails when a line of valid lua code is given to it if that valid line requires other variables declared before it.

meds
  • 21,699
  • 37
  • 163
  • 314

1 Answers1

1

Compile it. Call Lua.LoadString. That will give you compile-time errors (syntax errors). To find runtime errors, you're just going to need to run it.

Mud
  • 28,277
  • 11
  • 59
  • 92
  • This works but what I ended up needing to do is enclose the lua function string in a "function test()" [lua to validate] + "end" – meds Aug 22 '13 at 07:42