Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Step / debug

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Step / debug Page: [1]
Login
Message << Older Topic   Newer Topic >>
Step / debug - 11/15/2021 8:46:05 AM   
nukkxx5058


Posts: 2904
Joined: 2/3/2005
From: France
Status: online
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 ?
Post #: 1
RE: Step / debug - 11/15/2021 12:19:09 PM   
BeirutDude


Posts: 2578
Joined: 4/27/2013
From: Jacksonville, FL, USA
Status: offline
My use is very simple (I'm not nearly as proficient as I would like to be) so I just use the game editor.

_____________________________

"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!

(in reply to nukkxx5058)
Post #: 2
RE: Step / debug - 11/15/2021 9:46:23 PM   
musurca

 

Posts: 114
Joined: 7/16/2020
Status: offline
quote:

a) Do you guys use an external editor to type code or do you use the game Lua console ?


I write everything in Visual Studio Code, a free IDE which includes Lua language highlighting and linting (basic sanity checks for your code), then copy it into the CMO window later.

KnightHawk75 also created an excellent plugin for Visual Studio Code which recognizes CMO functions and provides some auto-complete and documentation: https://www.matrixgames.com/forums/tm.asp?m=5069590

quote:

b) Is there a way to run a code in debug mode, step by step ?


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.

What I generally do is embed ScenEdit_MsgBox() statements when testing code to print out the state of variables. I'll also paste individual functions or segments of code into the Lua Console in Editor mode and print() out state while testing.

< Message edited by musurca -- 11/15/2021 9:47:25 PM >

(in reply to nukkxx5058)
Post #: 3
RE: Step / debug - 11/16/2021 12:01:22 AM   
KnightHawk75

 

Posts: 1417
Joined: 11/15/2018
Status: offline
quote:

ORIGINAL: nukkxx5058

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.

quote:

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 >

(in reply to nukkxx5058)
Post #: 4
RE: Step / debug - 11/16/2021 6:33:13 AM   
nukkxx5058


Posts: 2904
Joined: 2/3/2005
From: France
Status: online
Thanks guys, very helpful. Re VS Code: in fact I installed several editors (Sublime text, zero brane --and I'm not fully satisfied with them) because I couldn't manage to get VS Code working ... Here's the message I get when running some code with VSCode. Couldn't find a fix.

Lua diretcory: D:\DEVELOP\LUA\Lua 5.1
VSCode: C:\Users\Home\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Visual Studio Code
VSCode working directory : D:\DEVELOP\VS Code






Attachment (1)

< Message edited by nukkxx5058 -- 11/16/2021 6:47:45 AM >

(in reply to KnightHawk75)
Post #: 5
RE: Step / debug - 11/17/2021 2:08:48 AM   
boogabooga

 

Posts: 438
Joined: 7/18/2018
Status: offline
If Visual Studio Code seems too complicated but the CMO Lua console seems too primitive, you could use what I do: Notepad++


(in reply to nukkxx5058)
Post #: 6
RE: Step / debug - 11/17/2021 3:16:42 PM   
KnightHawk75

 

Posts: 1417
Joined: 11/15/2018
Status: offline
That looks like some kind of basic configuration issue with your chosen setup, or config or debug config settings for the workspace or folder, or user. Hard to say what's exactly prompting that error but if I had to guess it's telling you to edit the associated settings.json or launch.json and adjust it with what it's telling you is the solution.

https://izziswift.com/vscode-how-to-set-working-directory-for-debug/ (this is for python but the basics of what it's telling you there should be the ~similar, just the line you're adding\changing is slightly different.)
I get lost in all the config options\files for VSCode too sometimes. File|Preferences|Settings|Features|Debug|Launch I think may be what you're looking as for where to make the change.


(in reply to boogabooga)
Post #: 7
RE: Step / debug - 11/17/2021 8:17:57 PM   
nukkxx5058


Posts: 2904
Joined: 2/3/2005
From: France
Status: online

quote:

ORIGINAL: boogabooga

If Visual Studio Code seems too complicated but the CMO Lua console seems too primitive, you could use what I do: Notepad++



Won't work neither. It's a config issue. Sublime Text works and is good but reminds me to pay for it every few hours. Zero Brane works as well but I really would like VS Code because I was using it to learn some C# and I like it.

(in reply to boogabooga)
Post #: 8
RE: Step / debug - 11/17/2021 8:18:53 PM   
nukkxx5058


Posts: 2904
Joined: 2/3/2005
From: France
Status: online

quote:

ORIGINAL: KnightHawk75

That looks like some kind of basic configuration issue with your chosen setup, or config or debug config settings for the workspace or folder, or user. Hard to say what's exactly prompting that error but if I had to guess it's telling you to edit the associated settings.json or launch.json and adjust it with what it's telling you is the solution.

https://izziswift.com/vscode-how-to-set-working-directory-for-debug/ (this is for python but the basics of what it's telling you there should be the ~similar, just the line you're adding\changing is slightly different.)
I get lost in all the config options\files for VSCode too sometimes. File|Preferences|Settings|Features|Debug|Launch I think may be what you're looking as for where to make the change.




Thanks, will search in this direction ...

(in reply to KnightHawk75)
Post #: 9
RE: Step / debug - 11/20/2021 7:11:24 AM   
nukkxx5058


Posts: 2904
Joined: 2/3/2005
From: France
Status: online
Ok, I finally managed to get VScode working. WIll be able to try KnightHawk75 plugin :-)

(in reply to nukkxx5058)
Post #: 10
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Step / debug Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.287