Jump to content
Sign in to follow this  
ayser

execVM in a button?

Recommended Posts

I'm trying to make a button, but everytime I try to load up the mission with this bit of code added to it I crash, specifically on the "onbuttonclick" line. How can I fix this? :confused:

	class btnDistanceAtmo : w_RscButton {
		text = "Atmo";
		onButtonClick = ["true execVM "Atmo.sqf";"];
		x = 0.32; y = 0.60;
		w = 0.125; h = 0.033 * safezoneH;
	};

Share this post


Link to post
Share on other sites

Not sure, but try changing the line to:

onbuttonClick = ["true execVM ""Atmo.sqf"";"];

Note the double quotes - this tells the parser not to break out of the outer quotation marks. Otherwise it looks like:

"true execVM "

Atmo.sqf

";"

Share this post


Link to post
Share on other sites
Not sure, but try changing the line to:

onbuttonClick = ["true execVM ""Atmo.sqf"";"];

Note the double quotes - this tells the parser not to break out of the outer quotation marks. Otherwise it looks like:

"true execVM "

Atmo.sqf

";"

More .sqf goodness :)

Share this post


Link to post
Share on other sites

Loved it! :) But now i'm trying to go a little bit further. I'm trying to make it toggle itself.. But I keep getting an error, again, on the "onButtonClick" line. Any clues?

		onButtonClick = "
if (_Atmo == 1) then {
_Atmo == 0;
false execVM ""Atmo.sqf"";
}
if (_Atmo == 0 ) then { 
true execVM ""Atmo.sqf"";
_Atmo == 1
}
";

Error message: "Config: End of line encountered after onButtonClick"

Am I just not able to do all of the if's, and thens? Just 1 line?

Share this post


Link to post
Share on other sites

not really sure why you are doing it that way.. if the button is in a dialog GUI.. then find the dialog.hpp and add the action = {} line to the button.

example:

class eGUI_buttonTest_3: RscButton
{
idc = 72308;
action = "[testVeh_2] execVM '_tempShowClass.sqf'";

text = "T3"; //--- ToDo: Localize;
x = 0.5 * safezoneW + safezoneX;
y = 0.276029 * safezoneH + safezoneY;
w = 0.0393783 * safezoneW;
h = 0.0279964 * safezoneH;
colorText[] = {0,255,255,1};
colorBackground[] = {0.1,0.1,0.1,0.72};
tooltip = "Test Button 3"; //--- ToDo: Localize;
};

good place to look as well:

http://community.bistudio.com/wiki/DialogControls-Buttons

Edited by Loki
added link

Share this post


Link to post
Share on other sites

move all the logic into the executing script and pass a variable to the script for evaluation - you can't evaluate code in an hpp file.

Share this post


Link to post
Share on other sites

I did the methods you suggested, and now it doesn't crash :) but, once again, i'm running into problems :(

I've got an init.sqf with

_Atmo == false;

And a script with this in it...

#include "init.sqf";

if (_Atmo == true) then {
_Atmo = false;
false execVM "Atmo.sqf";
} else { 
true execVM "Atmo.sqf";
_Atmo = true
}

I keep getting an error "|#|_Atmo == false;#line 1"... Error ==: Undefined fariable in expression: _atmosphere

What am I doing wrong? I've tried doing _Atmo == 0; but nothing seems to work for me

Edit -

So I edited the code a bit, practicing my trash coding skills, and I'm getting errors on "Atmo = 1;", Why though?

if(Atmo == 1) exitWith
{
player globalChat "ACTION";
};

Atmo = 0;

if(Atmo == 0) then
{
hint "1";
} else { 
Atmo = 1; 
hint "2"; 
};

---------- Post added at 09:49 PM ---------- Previous post was at 08:44 PM ----------

Getting super low on the list, doubt anyone will see this.... sooooo.......

Badabump

Edited by ayser

Share this post


Link to post
Share on other sites

init.sqf

Atmo=false;

In your button hpp file

class btnDistanceAtmo : w_RscButton {
text = "Atmo";
[color=#000000][font=Lucida Console]onButtonClick = "[/font][/color][] execVM ""[color=#3E3E3E]Atmo.sqf[/color]""[color=#000000][font=Lucida Console]";[/font][/color]
x = 0.32; y = 0.60;
w = 0.125; h = 0.033 * safezoneH;
};

Atmo.sqf

if (Atmo == true) then {
Atmo = false;
[] execVM "AnotherScript1.sqf";
} else { 
Atmo = true;
[] execVM "AnotherScript2.sqf";   
};

starting a variable with an underscore _ makes it local to the script its created (there's more to it than that, but as a general rule of thumb) - read this for more info, code provided is just off the top of my head so consider untested, although it should be good..

Share this post


Link to post
Share on other sites

if (Atmo |#|== true) then {
Atmo = false;
fals...'
entry,Display (dialog,Control,Network Object, Team member,Task,Location

That's the error I get :(

Share this post


Link to post
Share on other sites

you gonna need to give us more info to work with.. post the mission

Share this post


Link to post
Share on other sites

just saw this before bed will take a look tomorrow

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  

×