Debugging

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
PirateJock_Wargamer
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 325
Joined: Fri Apr 17, 2009 9:21 pm
Location: North West, UK
Contact:

Debugging

Post by PirateJock_Wargamer »

Anybody know how to use ...

F3 – Debug Current Unit script
F4 – Debug AI script
F5 – Debug scenario script

I believe I've got debug enabled in my user.txt file - there are a few debug related ones and as far as I know all are set as 1 (not on a computer with game on so can't check exactly what I've got set). F6 shows the script log window. Shift-F7 shows some AI info; while F7 reveals all units and associated Team.

Any hints greatfully received :D

Cheers
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

To use these you will need to be (a) running in windowed mode, (b) run in a size that give you a good amount of room to the right of the window (e.g. running 1280x1024 on a 1680x1050 screen would be a good example).

Then, when you hit the key you should see a debug window appear on the right of the game window, with the ability to check variable values, set breakpoints, etc. It's somewhat primitive (well, compared to say Visual Studio, it's about on par with Xcode :evil: ) but it can really help if you're having trouble and logging isn't cutting it.

Note you need the script to be running for it to 'latch on' to it - which is a pain for the AI I know. But we're working to improve all these tools, so any feedback on them, even if it's just that you're finding them useful, is always valued.

Cheers

Pip
PirateJock_Wargamer
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 325
Joined: Fri Apr 17, 2009 9:21 pm
Location: North West, UK
Contact:

Post by PirateJock_Wargamer »

Hi Pip

That'd be it then ... use the not-fullscreen option and I get a debugger showing :) Now just need to figure out how it runs.

What do you mean by "Note you need the script to be running for it to 'latch on' to it" ?

I'd assumed/hoped that if I press F3 - to show the debugger - and then select one of my units, if I ask it to move I'd be able to step through the script or set a break and run to that point. At the moment that's not happening. I've tried various orders of pressing buttons to see if anything triggers the debugger to go to the script. Every time it goes to first line of script for FUNCTION DrawSelectedUI(me). I've tried stepping it on and that does work, i.e. it moves on, but what I'm seeing is the script for unit's info box at the bottom left hand side of the screen isn't it. Is that correct?

Any hints?

Thanks
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

Once you are in the script, then you can find where you want to break (for example the ALL_MOVE function) and set a breakpoint there. Then when you move the unit it will break.

Ideally it would allow you to set breakpoints for a given unit script without the script being in focus, but there are some technical issues with doing that. If it's something people use a lot we can devote some more time to it, but it's a fairly power user feature really.

As a note, you can add a

break ;

command to the script and it will cause the debugger to open at that point (IIRC - not looking at the code atm!)

Cheers

Pip
PirateJock_Wargamer
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 325
Joined: Fri Apr 17, 2009 9:21 pm
Location: North West, UK
Contact:

Post by PirateJock_Wargamer »

Hi Pip

Thanks for that.

break ; is fine for setting stop points and useful. It does open the debugger when reached. Don't think there's any need for anything fancier.

Cheers
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Debugging

Post by enric »

Pip, is it supposed that the debug mode works on a MacOS?

When in debug mode:
F6 open a small window on the right bottom of the play window, there is nothing inside.
F7 reveals all units and associated Team.
All other F keys do nothing.

The info for each friendly unit reveals the tile coordinates.
The info for enemy units additionally shows UD: -1, -1 (values may change) what is the meaning of those values? (unit destination, maybe?)
Also each coordinate has a parenthetical value, at the beginning I supposed it was the terrain level, but I do not think so now, what is it?


MacOS 10.7.4
MAcBookAir
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Debugging

Post by pipfromslitherine »

Unfortunately debug mode isn't operative on the Mac. The tools were all built using the Windows SDK, and it wasn't going to be time practical to duplicate it using the OSX calls. If I get a chance to improve this area of the tools I will almost certainly make it all ingame and thus cross platform.

UD is indeed the unit destination. The () value after the tile coords is I believe the LOS value for that tile for your side.

Cheers

Pip
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Debugging

Post by rf900 »

The action seems to stop at some points even if no break points are set, does that mean there is something wrong in the script? Clicking on step will move on and but sometimes it takes a while clicking on other screen parts for the game to continue without halting.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Debugging

Post by pipfromslitherine »

If you hit the key, then it will stop in the script if it is running. You should be able to continue the game on, it doesn't stop in the debugger if there is an error. Step will only go to the next instruction.

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”