debug codes don't work

Started by HandsFree, Sun 20/07/2014 17:28:34

Previous topic - Next topic

HandsFree

Started my game in version 3.2.1 from the default game template. Now I opened it in 3.3.0 and the debug options don't seem to work.

In on-key-press I have:
Code: ags

  if (keycode == eKeyCtrlS)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV)  Debug(1,0);  // Ctrl-V, version
  if (keycode == eKeyCtrlA)  Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == eKeyCtrlW && game.debug_mode) 
    player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 

The ctrl-V always gives version info, the other keys don't do anything. It doesn't matter if I set 'Enable Debug Mode' to true or false in general settings. Behaviour stays the same.

Am I missing something? I did delete some stuff from on-key-press dealing with other key combinations. Should there be some code anywhere to make this work again?

Crimson Wizard

They should work...
They work in the game created from Default template.

Do you use any script modules, that override "on_key_press"? Does any of you room scripts override that function?
Any plugins maybe?

Can you post the whole "on_key_press" function here?

Also, you may make this test:
Code: ags

if (keycode == eKeyCtrlX)
{
   Display("Debug 3 called");
   Debug(3,0);  // Ctrl-X, teleport to room
}

and see if anything is displayed on screen.

HandsFree

Hm, I deleted everything I don't need, so I could post a better readable on_key_press and now it works mostly.   :-\
Only thing is that the ctrl-V still always gives version info, even if debug mode is false. Is it supposed to be like that?

Code: ags

function on_key_press(eKeyCode keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.
  

  // DEBUG FUNCTIONS

  if (keycode == eKeyCtrlS)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV)  Debug(1,0);  // Ctrl-V, version
  if (keycode == eKeyCtrlA)  Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == eKeyCtrlW && game.debug_mode) 
    player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 
}

Ghost

Quote from: HandsFree on Sun 20/07/2014 19:53:16
Only thing is that the ctrl-V still always gives version info, even if debug mode is false. Is it supposed to be like that?

That's intentional, nothing to worry about (It also takes some heavy trickery to disable the Alt-X shortcut. Not that someone would WANT to do that ;))

Monsieur OUXX

Well actually I DO want to disable Ctrl+V, because it messes up my copy/paste shotcuts!!! (wtf)
Is there any way at all? ;-D
 

Gurok

#5
Quote from: Monsieur OUXX on Mon 17/11/2014 12:18:17
Well actually I DO want to disable Ctrl+V, because it messes up my copy/paste shotcuts!!! (wtf)
Is there any way at all? ;-D

You could write a plugin that handles the keypress. The engine won't show version info on Ctrl+V if that key combination is handled by a plugin.

I think the engine code that handles Ctrl+V should actually be removed. It's better to define it in the keypress function and let the game developer choose whether it's included in the final release. What do you think, CW? We could put it behind a loaded_game_file_version check.
[img]http://7d4iqnx.gif;rWRLUuw.gi

monkey0506

Quote from: Ghost on Sun 20/07/2014 21:04:35That's intentional, nothing to worry about (It also takes some heavy trickery to disable the Alt-X shortcut. Not that someone would WANT to do that ;))

Heavy trickery? You mean like:

Code: ags
game.abort_key = -1;


I mean, that is some pretty hardcore, advanced-level coding right there. 8-)

Crimson Wizard

#7
Quote from: Gurok on Mon 17/11/2014 12:38:06
I think the engine code that handles Ctrl+V should actually be removed. It's better to define it in the keypress function and let the game developer choose whether it's included in the final release. What do you think, CW? We could put it behind a loaded_game_file_version check.
Yes, this is.... strange.
The version is actually shown with calling "Debug(1, 0)". However, it only works if the game is built with debug mode, therefore there must be other function to display engine info, "System.DisplayRuntimeInfo", or something like that (better name anyone?).
EDIT: or rather a string property, because displaying something is a separate function.

And yes, I do not see any other way atm than to use dummy plugin that catches this key.

BTW, Monsieur OUXX, what is the version of AGS you are using for your game?

Monsieur OUXX

I'm using 3.3.0 RC1. I'm working in debug mode and didn't try in "release" mode because I read everywhere that it's the same in release mode. I can try in release mode if you want.

I understand the pros and cons of each solution:
- Leaving a permanently-enabled shortcut is more reliable for complex or professional games, when the developers can ask the client to double-check the build version anytime, even when they forgot to include such shortcut.
- Adding an explicit Call to Debug(1,0) in on_key_press is more consistent with the rest of the global script.

COMPROMISE : how about making the shortcut more complex, like "Ctrl+Alt+V"? My only issue right now is that it overlaps with the almost-universal "Paste" shortcut (Ctrl+V). Ctrl+Alt+V is much more rare. I suppose that would be super easy to change in the next 3.3.x release.
 

Crimson Wizard

#9
Quote from: Monsieur OUXX on Thu 20/11/2014 14:53:55
I'm using 3.3.0 RC1. I'm working in debug mode and didn't try in "release" mode because I read everywhere that it's the same in release mode. I can try in release mode if you want.
No, there is no difference. The Ctrl+V is hardcoded and works regardless of mode.
What I was saying is that calling Debug(1, 0) does the same too, but it works only in debug mode.

Quote from: Monsieur OUXX on Thu 20/11/2014 14:53:55
I understand the pros and cons of each solution:
- Leaving a permanently-enabled shortcut is more reliable for complex or professional games, when the developers can ask the client to double-check the build version anytime, even when they forgot to include such shortcut.
Since 3.3.0 engine also writes its version to the log. Log is enabled by putting a "log=1" line into acsetup.cfg.
Pros: logging is universal and writes a lot of useful info.
Cons: this method requires more actions from the user.

Quote from: Monsieur OUXX on Thu 20/11/2014 14:53:55
- Adding an explicit Call to Debug(1,0) in on_key_press is more consistent with the rest of the global script.
This won't work without debug mode, i.e. final users will almost never be able to use this. If we are to suggest gamedevs an explicit function, we'd better introduce something new (like the property example I mentioned above).

Monsieur OUXX

Quote from: Crimson Wizard on Thu 20/11/2014 15:04:18
If we are to suggest gamedevs an explicit function, we'd better introduce something new (like the property example I mentioned above).
Well, as you wish, I don't really care. I just wat to be able to code my Ctrl+V ;)
 

Crimson Wizard

OK, Ctrl+Alt+V may work for now.

Gurok

#12
Awww! I just *just* made a pull request to make this programmable: https://github.com/adventuregamestudio/ags/pull/213
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Well, we could have both; besides Monsieur OUXX would like to have this in 3.3 update rather than in 3.4 (because his game in production is 3.3)

Gurok

Just wanted to add: the system Ctrl+V / Ctrl+Alt+V shortcut doesn't work if a blocking function is running. So it's not available at any time, it's just guaranteed to be present if we leave it hard coded.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Tue 25/11/2014 12:04:15
Just wanted to add: the system Ctrl+V / Ctrl+Alt+V shortcut doesn't work if a blocking function is running. So it's not available at any time, it's just guaranteed to be present if we leave it hard coded.
Yes, true, also it displays it using default font number, which may be unreadable in some circumstances. So I believe exporting a property was a right way to go.
I just do not want to push much new features to 3.3, these updates are rather for bug fixing.

SMF spam blocked by CleanTalk