Create account / Log in

Debug mode? Text editor?

Talk about module design ideas and techniques.

Moderators: uckelman, Tim M

Debug mode? Text editor?

Postby m3tan » May 21st, 2020, 1:31 am

I'm an experienced programmer but new to Vassal. Does Vassal have a debug mode or any other tools to help with programming that I'm not seeing? It would great to monitor and edit properties in realtime. I've resorted to creating "cheat-code" keyboard shortcuts and creating a giant text label that I'm constantly adding and removing $labels$ as I need to monitor them. Is there an easier way?

Also, I'd much rather just use a text editor like Notepad++ than fumble around with the graphical interface. Is that feasible or is the code for the buildfile brittle? i.e. typos completely break modules...

Thanks and sorry if these questions are silly. I'm stumbling around in the dark...
User avatar
m3tan
 
Posts: 85
Joined: August 12th, 2018, 11:49 pm

Re: Debug mode? Text editor?

Postby JoelCFC25 » May 21st, 2020, 1:48 am

The buildfile is XML, but it's pretty vile-looking and you won't be able to reliably do much of anything apart from emergency edits like "I just deleted the Player Sides node which can't be added back in the Editor and I need to paste it back in from another module's buildfile".

There is no debugging mode, so lots of Report traits and text labels to monitor values of things is about the best you can do.
JoelCFC25
 
Posts: 698
Joined: October 12th, 2010, 5:15 pm
Location: Minnetrista, MN

Re: Debug mode? Text editor?

Postby m3tan » May 21st, 2020, 2:11 am

Well at least an XML file means a text editor can be used to search for typos and globally change/rename properties with a search function. It's also a great way to find duplicates or properties that are accidentally misnamed like "German_Infantry" and "Germany_Infantry". One of those could take hours to find with the Module Editor. Notepad++ has a great split-screen for comparing two versions of a text document as well. Great for finding new code that broke your program...
User avatar
m3tan
 
Posts: 85
Joined: August 12th, 2018, 11:49 pm

Re: Debug mode? Text editor?

Postby Cattlesquat » May 21st, 2020, 2:40 am

Yeah in November I was exactly where you are now. I do use XMLSPY to edit my buildFile and it's SUPER-useful for "search" and "search/replace" kinds of thing. Also for moving blocks-O-crud around. I do also create scads of Global Properties with it, e.g. when I need three groups of 20 global properties in a particular naming scheme -- global properties are safe to copy and duplicate. PIECES unfortunately have pretty hard-to-parse coding, but you CAN do search-and-replace with a reasonable amount of care. One word of warning there can be slight issues if you CREATE new pieces in it (by duplicating other ones) and don't give them unique gpid's -- it will eventually straighten itself out but if you just avoid creating new pieces that way you'll be... safer. BTW the buildFile, if you haven't found it, is inside your VMOD file which is actually literally just a ZIP file renamed to the VMOD file extension -- so just get 7Zip or whatever and you can pop your buildFile out to scrud around with.

Meanwhile you've obviously discovered "lots of text labels". I will also insert "Report" traits in various places to see if triggers are firing or what they think is in the properties at the time they're hitting or not hitting their matching expression.

FINALLY, since you say experienced programmer -- Vassal IS an open-source Java project, and so if you want to REALLY "dive into the abyss", you can get Eclipse running (e.g. http://www.vassalengine.org/wiki/Eclipse_setup is only slightly out of date) pull down the Vassal source for 3.2.17, and go to town. As in ALL THE THINGS -- breakpoints, what's happening in expressions, etc, etc. But it does mean you're debugging the java source for the whole platform, and so there's a certain amount of drinking-from-the-firehose when all you really want to know is "did this global property get set to 1 or not". It's a deep deep rabbit hole, but I followed it and it led to... goodness.

I have a custom "chat" class for the chat window, and I've started to experiment with "console-style" commands for it (e.g. "/force chatter height 160"). I'm toying with setting it up to let me query & set properties and stuff on the chat line. When I start to get a feel for "how long it's going to be until Vassal 4" that will probably nudge me toward either getting that all nice and set up or else writing some similar thing for Vassal 4... soooo many rabbit holes.

Brian
User avatar
Cattlesquat
 
Posts: 489
Joined: December 2nd, 2019, 4:57 pm
Location: Baltimore, Maryland, USA

Re: Debug mode? Text editor?

Postby Brent Easton » May 21st, 2020, 3:26 am

Is there an easier way?


No, that's pretty much it. I've considered writing some sort of debug mode at different times over the years, but the Vassal security model is also brittle, to say the least, and it would just open up too big a can of worms.

is the code for the buildfile brittle? i.e. typos completely break modules...


Yep. The buildfile is xml and can be manipulated with xml tools or standard text editors without too much problem. Gross edits like cutting and pasting lines is ok, as is the search and replace of obvious text strings like command names and image file names.

However, the data within some of the xml values representing piece definitions and the like is not designed to be edited externally and is EXTREMELY brittle. Save often.
User avatar
Brent Easton
 
Posts: 2962
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Debug mode? Text editor?

Postby shilinski » May 21st, 2020, 4:13 pm

Debugging Vassal takes me back to the days when I programmed in FORTRAN. Symbolic debuggers to me are life itself. I have not done what Cattlesquat has done (Eclipse) because I know I’ll just start fixing bugs, and those days are behind me. Anyway, here’s some things I do:

The Inventory window can be very helpful in dumping properties en masse, especially for pieces that seem to have vanished.

Sometimes I will create a special piece whose only job is to tell me its X and Y location via the text trait. It can be very helpful laying out orderly and precise “send to” locations. This is more a layout feature than a debugging one.

You can add a report trait to any piece that is linked to a key code (e.g. control-alt-F1) that has no function in the piece. It won’t show up in the right click menu, but if you select the piece and hit the key code anyways, the piece will spill its guts, i.e. print everything you put in the report string in the chat window. It’s a nice way to see the properties it sees at any time.
shilinski
 
Posts: 165
Joined: December 22nd, 2007, 8:46 am
Location: Laurel, Maryland

Re: Debug mode? Text editor?

Postby m3tan » May 21st, 2020, 4:51 pm

Thanks for the tip on the report trait. That is going to be very useful.

Haha! I started programming with FORTRAN 90, unless you count BASIC on my Atari. Yeah five years ago I fell down the rabbit hole of trying to debug TripleA, another Java-based tabletop boardgame engine for Axis&Allies style games. Never again. I hate trying to work on other people's code. I'm a perfectionist to a fault - I even fix blank lines and uneven spacing or tabs. I compulsively start reorganizing hierarchies so everything is orderly and I'll rewrite code that works because inefficiency drives me nuts. Best not to even know it exists or I'll lie awake at night wanting to fix something I saw that was poorly written...
User avatar
m3tan
 
Posts: 85
Joined: August 12th, 2018, 11:49 pm


Return to Module Design

Who is online

Users browsing this forum: No registered users and 2 guests