Jump to content

Recommended Posts

Hello,

 

Scripting question here. I've done several Googling sessions and haven't found anything. In a mission framework I am creating, I have added a button to the escape menu using the onPauseScript setting in my description.ext to run this code to add a button:

 

_menu = _this select 0;

_adminButton = _menu ctrlCreate ["RscButton",9998];

  // Move it to the position
  _adminButton ctrlSetPosition [0,0];
  // Set the text
  _adminButton ctrlSetText "Console";
  // Add the event handler to execute the console script. TODO: Close the escape menu before opening
  _adminButton ctrlAddEventHandler ["buttonClick", {_menu closeDisplay 0; player spawn wmc_fnc_openConsole}];

 

This works, as far as it creates the dialog, but it leaves the escape menu open, which in turn causes problems with VCOM's menu, plus it's just annoying. I have tried several things in place of "_menu closeDisplay 0;" including closeDialog. I don't know if I'm doing it right, but I haven't been able to find much documentation on this. Is there a way to close the escape menu through scripting, or even just simulate the key press of the ESC key to close it?

 

Thanks,

Nightwolf

Share this post


Link to post
Share on other sites

The display is called RscDisplayInterrupt and has an IDD of 49, can be found by querying the ui namespace variable of the displays name...

uinamespace getvariable "RscDisplayInterrupt"

 

The reason your variable _menu does not work is as once inside the eventhandler this variable is undefined. As the eventhandlers code is deferred to be run when the event happens (button pushed) and as such knows nothing about the code that set it up. You can either use..

findDisplay 49 closeDisplay 1

OR

(uiNamespace getVariable "RscDisplayInterrupt) closeDisplay 1

  • Like 4

Share this post


Link to post
Share on other sites
6 hours ago, Larrow said:

 


findDisplay 49 closeDisplay 1

 

 

Thank you so much, this is exactly what I was looking for! I didn't realize that the eventHandler won't accept variables from the script, so another thing to add to the knowledge bank. I'm still relatively new so thanks for the help.

Share this post


Link to post
Share on other sites

Actually an eventhandler can contain a variable from the script. I learned that from KillzoneKids blog a few days ago when I was examining the compile command. This is what you can do:

_myVarInScript = 100;
player addEventhandler ["Fired", format ["systemChat str %1;",_myVarInScript]];

http://killzonekid.com/arma-scripting-tutorials-a-few-tips-and-tricks/

 

As it seems there are some limitations though. Sometimes the variable can't be passed if it contains spaces.

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, 7erra said:

Actually an eventhandler can contain a variable from the script

Then your not actually using the variable inside the EH, your formatting the variables reference/value into the EHs code. May seem like semantics but there is a distinct difference.

 

Trying to format certain things like Objects, Ctrls, Displays, Tasks or any other Arma reference type variables will create errors.

For instance Objects...

player addEventHandler [ "Fired", format[ "systemchat name %1", player ] ];
15:12:51 Error in expression <systemchat name B Alpha 1-1:1 (Dev)>
15:12:51   Error position: <Alpha 1-1:1 (Dev)>
15:12:51   Error Missing ;

16 hours ago, 7erra said:

As it seems there are some limitations though. Sometimes the variable can't be passed if it contains spaces.

Nothing to do with spaces. B Alpha 1-1:1 (Dev) is a valid string representation of an Object reference because format was used, but the command name needs an Object.

 

With a varName..

_varName = "p1";
player setVehicleVarName _varName;
missionNamespace setVariable[ _varName, player ];
player addEventHandler [ "Fired", format[ "systemchat name %1", _varName ] ];

Which despite setVehicleVarName causing a change in the String representation of the objects reference, is no different to a global variable missionNamespace setVariable.

 

Or the quick way if you do not care what the varName actually is

player addEventHandler [ "Fired", format[ "systemchat name %1", player call BIS_fnc_objectVar ] ];

Or by using netID

player addEventHandler [ "Fired", format[ "systemchat name ( '%1' call BIS_fnc_objectFromNetId )", player call BIS_fnc_netId ] ];

 

  • Like 3

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

×