Jump to content
Sign in to follow this  
moricky

Debug Console for ARMA 2

Recommended Posts

Found a bug in the current debugtool that might annoy many users - each time you type a number it executes the line matching the number. The tooptip for the buttons say Ctrl+1, Ctrl+2, but they react on only 1, 2 and so on. The fix is easy, in scripts\init.sqf:

	//--- Set event handlers
	DEBUG_DISPLAY displayaddeventhandler ["keydown","
		_key = _this select 1;
		_ctrl = _this select [color="Red"]3[/color];
		[color="red"]if (_ctrl) then {[/color]
			switch (_key) do {
				case 2: {call compile (ctrlText 316101);};
				case 3: {call compile (ctrlText 316102);};
				case 4: {call compile (ctrlText 316103);};
				case 5: {call compile (ctrlText 316104);};
				case 6: {call compile (ctrlText 316105);};
				case 7: {call compile (ctrlText 316106);};
			};
		[color="red"]};[/color]
		false
	"];

Changed/added code in red. Now you need to press the Ctrl + number key for the code to compile.

The annoying thing was:

line 1: skiptime 3 (execute)

line 2: 0 setovercast 1 (executes line 1 when you pressed the 1 key since it didn't check for control key pressed).

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

Further slightly enhancing the above, so that enter keys work properly depending on where you're typing:

	//--- Set event handlers
	DEBUG_DISPLAY displayaddeventhandler ["keydown","
		_key = _this select 1;
		_ctrl = _this select 3;
		if (_ctrl) then {
			switch (_key) do {
				case 2: {call compile (ctrlText 316101);};
				case 3: {call compile (ctrlText 316102);};
				case 4: {call compile (ctrlText 316103);};
				case 5: {call compile (ctrlText 316104);};
				case 6: {call compile (ctrlText 316105);};
				case 7: {call compile (ctrlText 316106);};
			};
		};
		false
	"];
[color="Red"]		//--- Set event handlers per control to react to enter keys
	DEBUG_CMD1 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316101)};"];
	DEBUG_CMD2 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316102)};"];
	DEBUG_CMD3 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316103)};"];
	DEBUG_CMD4 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316104)};"];
	DEBUG_CMD5 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316105)};"];
	DEBUG_CMD6 ctrlAddEventHandler ["keydown","_key=_this select 1;if (_key == 28 || _key == 156) then {call compile (ctrlText 316106)};"];[/color]

The stuff in red is the new stuff. You may (I have already, but for other reasons) also have to add a dummy button to the dialog (one that doesn't do anything or show anything) that replaces CommandButton1's default parameter so that this isn't executed as well when you hit enter. Instead the dummy button gets the default flag, except when executed it's not actually doing something.

I tried forEach and "_key in _enterkeys" and whatnot to make it look better, but didn't work. Probably scope problems within the compiles.

Share this post


Link to post
Share on other sites

Added these by request from a friend - the ability to doubleclick in the fields to clear them:

	DEBUG_CMD1 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316101) ctrlSetText ''"];
	DEBUG_CMD2 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316102) ctrlSetText ''"];
	DEBUG_CMD3 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316103) ctrlSetText ''"];
	DEBUG_CMD4 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316104) ctrlSetText ''"];
	DEBUG_CMD5 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316105) ctrlSetText ''"];
	DEBUG_CMD6 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316106) ctrlSetText ''"];
	DEBUG_VAR1 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316011) ctrlSetText ''"];
	DEBUG_VAR2 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316021) ctrlSetText ''"];
	DEBUG_VAR3 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316031) ctrlSetText ''"];
	DEBUG_VAR4 ctrlAddEventHandler ["MouseButtonDblClick","(findDisplay 316000 displayCtrl 316041) ctrlSetText ''"];

Yea, I know, could be prettier, but you get the idea. Also added to the while{running} loop that the DEBUG_OUT1-4 are cleared if the inputs are empty, so as to not display crap:

		if (ctrlText 316011 != "") then {DEBUG_OUT1 ctrlSetText format ["%1",call compile (ctrlText DEBUG_VAR1)];} else {DEBUG_OUT1 ctrlSetText ""};
		if (ctrlText 316021 != "") then {DEBUG_OUT2 ctrlSetText format ["%1",call compile (ctrlText DEBUG_VAR2)];} else {DEBUG_OUT2 ctrlSetText ""};
		if (ctrlText 316031 != "") then {DEBUG_OUT3 ctrlSetText format ["%1",call compile (ctrlText DEBUG_VAR3)];} else {DEBUG_OUT3 ctrlSetText ""};
		if (ctrlText 316041 != "") then {DEBUG_OUT4 ctrlSetText format ["%1",call compile (ctrlText DEBUG_VAR4)];} else {DEBUG_OUT4 ctrlSetText ""};

Something to consider for the official one in A3? I tried to get some right click functionality in there, but was unsuccessful, which is why I went with doubleclick instead.

Share this post


Link to post
Share on other sites

I was wondering, how could you change the bind key to something else, my wasteland server has a "Continue" box on the escape menu, everytime I press space or enter it just closes the esc menu

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×