Hi, I have two questions about using Lua in CMO.
a) Do you guys use an external editor to type code or do you use the game Lua console ?
b) Is there a way to run a code in debug mode, step by step ?
a:) See Musurca's answer I use, VSCode + sumneko plugin + my own CMO library made for that sumneko plugin (check it out) like idk...75% of the time, 25% just the in game editor. Basically after I get past say 50 or so lines I flip to VScode and then use ScenEdit_RunScript(...file I'm working on in vscode) in the in-game editor to 'run' it during developement. I usually have snaketail open in the background to monitor the running lua session log for output (when doing that). VSCode and the Lua plugins will aid greatly in avoiding simple syntactic errors and base Lua 5.3 language understanding and context help, as it has built in contextual lua 5.3 manual (just remember to set the environment to 5.3 instead of default 5.4). My library plugin for the plugin then helps with the CMO syntax, function names, and to some degree contextual help.
b) Generally no, lots of times I just take the time upfront and loadup all my code with conditional debugging print statements that queue off a dbglevel var, as well as trap for errors where I think they can happen (use of pcall and xpcall) and handle them if possible. Half my code ends up being related to debug logging and testing for unexpected values. As whatever i'm doing matures i remove lines that were there just for development (every print statement can be a performance hit.), and turning the rest off via setting my dbglevel var off.
Sadly, no, not as far as I know. It would be great to have a way to set up breakpoints and examine the state of variables in a CMO scenario, but I think that's not possible in the Commercial version.
There technically are ways to step through the code (more at the game engine level than lua language line by line) with an external debugger with breakpoints, but idk if I should really talk about it, and given the very high level of obfuscation applied to the .net game code it's not going to be of that much value, at least not for the average user or average problem. That said if you want to invest an inordinate amount of time, I have been able to dig deep into some issues and find some bugs\request some enhancements that way over the years.
https://www.matrixgames.com/forums/tm.asp?m=5032286 (post 17) was particularly a tough and rather obscure one to track down for example, that was impossible to get to the root of without stepping though actual code (and already understanding pieces of the system from past investigations). That said that level of debugging is probably not what OP had in mind.
< Message edited by KnightHawk75 -- 11/16/2021 12:02:04 AM >