Jump to content
JR Nova

sliderSetRange Not Changing Values

Recommended Posts

I'm trying to get a time limit slider to work in a dialog with values from 5 minutes to 120 minutes and if the slider's value is over 120 minutes then it changes to no time limit. The numbers show up in game but the values on the slider only go from 0 minutes to 10 minutes. Is there something I'm doing wrong?

 

Snippets from the scripts involving this slider:

 

bfMenu1Begin.sqf - script that opens dialog and sets values for the sliders.

sliderSetRange [1904, 5, 121];
sliderSetSpeed [1904, 1, 10];
sliderSetPosition [1904, GAMETIME];

_say="Time Limit : "+str GAMETIME+" Minutes";if(GAMETIME==121)then{_say="No Time Limit ";};ctrlSetText [1005, _say];

bfMenu1.hpp

		class nova_slider_timeLimit: RscSlider
		{
			idc = 1904;
			onSliderPosChanged = "nul=[5]execVM'settings\bfMenu1.sqf';";

			x = 0.565625 * safezoneW + safezoneX;
			y = 0.388 * safezoneH + safezoneY;
			w = 0.18375 * safezoneW;
			h = 0.042 * safezoneH;

		};
		class nova_text_time: RscText
		{
			idc = 1005;

			text = "Time Limit: XXXX Mins"; //--- ToDo: Localize;
			x = 0.591875 * safezoneW + safezoneX;
			y = 0.36 * safezoneH + safezoneY;
			w = 0.13125 * safezoneW;
			h = 0.028 * safezoneH;
		};

 

bfMenu1.sqf

_sb=_this select 0; _say=0;

if(_sb==5)then{
	GAMETIME=(floor (sliderPosition 1904)); _say="Time Limit : "+str GAMETIME+" Minutes"; if(GAMETIME==121)then{_say="No Time Limit";}; ctrlSetText [1005,_say];
};

 

Share this post


Link to post
Share on other sites

onSliderPosChanged

You pass 5 as an argument.

_select 0 - _control

_select 1 - _newValue

Your control IDC is 1904, it wants the control, not IDC.

Quote

params ["_control", "_newValue"];

You are overwriting it with 5. Remove it.

onSliderPosChanged = "0 = [] execVM 'settings\bfMenu1.sqf';";

 

Share this post


Link to post
Share on other sites

Well the thing is I can't remove 5 because that lets the script know which part I'm calling because I have other items on the menu, those were just the parts of the code regarding this particular slider.

 

Basically I'm creating a dialog with buttons that let you click on the map to choose a location for a battlefield (bfLoc) and bases (westBase & eastBase). It also has sliders to adjust the size of the battlefield (bfSize), how long the game will last (timeLimit), how many points to win (maxScore), & how many groups spawn (westGroups & eastGroups).

 

bfMenu1Begin.sqf - script that opens dialog and sets values for the sliders.

Quote

createDialog "nova_bfcreate_dialog";

waitUntil {dialog};
//_noEscKey = (findDisplay 901) displayAddEventHandler ["KeyDown", "if ((_this select 1) == 1) then { true } else { false }"];

disableSerialization;

sliderSetRange [1904, 5, 121];
sliderSetSpeed [1904, 1, 10];
sliderSetPosition [1904, GAMETIME];
sliderSetRange [1900, 400, 4000];
sliderSetSpeed [1900, 50, 50];
sliderSetPosition [1900, GAMEDISTANCE];

sliderSetRange [1901, 50, 1000];
sliderSetSpeed [1901, 10, 100];
sliderSetPosition [1901, GAMEKILL];
sliderSetRange [1902, 1, 10];
sliderSetSpeed [1902, 1, 2];
sliderSetPosition [1902, NumGrpWest];
sliderSetRange [1903, 1, 10];
sliderSetSpeed [1903, 1, 2];
sliderSetPosition [1903, NumGrpEast];

_say="Time Limit : "+str GAMETIME+" Minutes";if(GAMETIME==121)then{_say="No Time Limit ";};ctrlSetText [1005, _say];
_say="Battlefield Radius : "+str GAMEDISTANCE"m"; ctrlSetText [1000, _say];
_say="Max Kills / Destruction : "+str GAMEKILL+" / "+str GAMEMONEY+"";ctrlSetText [1002, _say];

 

bfMenu1.hpp

Quote

        class nova_button_bfLoc: RscButton
        {
            idc = 1601;
            action = "nul=[1]execVM'settings\bfMenu1.sqf';";

            text = "Set Battlefield Center"; //--- ToDo: Localize;
            x = 0.3425 * safezoneW + safezoneX;
            y = 0.794 * safezoneH + safezoneY;
            w = 0.118125 * safezoneW;
            h = 0.042 * safezoneH;
        };
        class nova_button_westBase: RscButton
        {
            idc = 1602;
            action = "nul=[2]execVM'settings\bfMenu1.sqf';";

            text = "Set West Base"; //--- ToDo: Localize;
            x = 0.250625 * safezoneW + safezoneX;
            y = 0.794 * safezoneH + safezoneY;
            w = 0.0721875 * safezoneW;
            h = 0.042 * safezoneH;
            colorText[] = {0,0,1,0.9};
        };
        class nova_button_eastBase: RscButton
        {
            idc = 1603;
            action = "nul=[3]execVM'settings\bfMenu1.sqf';";

            text = "Set East Base"; //--- ToDo: Localize;
            x = 0.480312 * safezoneW + safezoneX;
            y = 0.794 * safezoneH + safezoneY;
            w = 0.0721875 * safezoneW;
            h = 0.042 * safezoneH;
            colorText[] = {1,0,0,0.9};
        };

        class nova_slider_timeLimit: RscSlider
        {
            idc = 1904;
            onSliderPosChanged = nul=[5]execVM'settings\bfMenu1.sqf';";

            x = 0.565625 * safezoneW + safezoneX;
            y = 0.388 * safezoneH + safezoneY;
            w = 0.18375 * safezoneW;
            h = 0.042 * safezoneH;

        };
        class nova_text_time: RscText
        {
            idc = 1005;

            text = "Time Limit: XXXX Mins"; //--- ToDo: Localize;
            x = 0.591875 * safezoneW + safezoneX;
            y = 0.36 * safezoneH + safezoneY;
            w = 0.13125 * safezoneW;
            h = 0.028 * safezoneH;
        };

        class nova_slider_bfSize: RscSlider
        {
            idc = 1900;
            onSliderPosChanged = "nul=[4]execVM'settings\bfMenu1.sqf';";

            x = 0.565625 * safezoneW + safezoneX;
            y = 0.248 * safezoneH + safezoneY;
            w = 0.18375 * safezoneW;
            h = 0.042 * safezoneH;
        };
        class nova_text_bfSize: RscText
        {
            idc = 1000;

            text = "Max Rush Radius: XXXXm"; //--- ToDo: Localize;
            x = 0.591875 * safezoneW + safezoneX;
            y = 0.22 * safezoneH + safezoneY;
            w = 0.13125 * safezoneW;
            h = 0.028 * safezoneH;
        };
        class nova_slider_maxScore: RscSlider
        {
            idc = 1901;
            onSliderPosChanged = "nul=[6]execVM'settings\bfMenu1.sqf';";
            x = 0.565625 * safezoneW + safezoneX;
            y = 0.458 * safezoneH + safezoneY;
            w = 0.18375 * safezoneW;
            h = 0.042 * safezoneH;
        };
        class nova_text_maxScore: RscText
        {
            idc = 1002;
            text = "Max Kills / Destruction : XXXX / XXXXX"; //--- ToDo: Localize;
            x = 25 * GUI_GRID_W + GUI_GRID_X;
            y = 10 * GUI_GRID_H + GUI_GRID_Y;
            w = 14.5 * GUI_GRID_W;
            h = 1 * GUI_GRID_H;
        };

 

bfMenu1.sqf

Quote

_sb=_this select 0; _say=0;

//bfLoc button;
if(_sb==1)then
{
hint"Set Battlefield Center by Clicking on the Map.";
onMapSingleClick "'FireCen' setMarkerPos _pos;setFire=1;onMapSingleClick """";";
waitUntil {setFire==1};
"FireCen" setMarkerShape "ICON";
"FireCen" setMarkerColor "ColorOrange";
"FireCen" setMarkerText "Fire Center";
"FireCen" setMarkerType "mil_destroy";
"FireCen" setMarkerDir 45;
"Range2B" setMarkerShape "ELLIPSE";
"Range2B" setMarkerColor "ColorRed";
"Range2B" setMarkerBrush "Border";
"Range2B" setMarkerSize [GAMEDISTANCE,GAMEDISTANCE];
"Range2B" setMarkerPos getMarkerPos "FireCen";
setFire=2;
};

//westBase button;
if(_sb==2)then
{
hint (parseText "Set West Base by Clicking on Map <br/> <t color = '#FF0000'>This decides the direction of the battlefield, so place it far away!</t>");
onMapSingleClick "'WB' setMarkerPos _pos;'WB2' setMarkerPos _pos;'WCen' setMarkerPos _pos;setWB=1;onMapSingleClick """";";
waitUntil {setWB==1};
"WB" setMarkerShape "ICON";
"WB" setMarkerColor "ColorBlue";
"WB" setMarkerText "WEST BASE";
"WB" setMarkerType "mil_flag";
setWB=2;
};

//eastBase button;
if(_sb==3)then
{
hint"Set East Base by Clicking on Map <br/> This decides the direction of the battlefield, so place it far away!";
onMapSingleClick "'EB' setMarkerPos _pos;'EB2' setMarkerPos _pos;'ECen' setMarkerPos _pos;setEB=1;onMapSingleClick """";";
waitUntil {setEB==1};
"EB" setMarkerShape "ICON";
"EB" setMarkerColor "ColorRed";
"EB" setMarkerText "EAST BASE";
"EB" setMarkerType "mil_flag";
setEB=2 ;
};

//bfSize slider;
if(_sb==4)then{
    GAMEDISTANCE=(floor (sliderPosition 1900));_say="Battlefield Radius : "+str GAMEDISTANCE+"m";ctrlSetText [1000, _say];"Range2B" setMarkerSize [GAMEDISTANCE,GAMEDISTANCE];
};

//timeLimit slider;
if(_sb==5)then{
    GAMETIME=(floor (sliderPosition 1904)); _say="Time Limit : "+str GAMETIME+" Minutes"; if(GAMETIME==121)then{_say="No Time Limit";}; ctrlSetText [1005,_say];
};

//maxScore slider;
if(_sb==6)then{
    GAMEKILL=(floor (sliderPosition 1901)); GAMEMONEY=800*GAMEKILL; _say="Max Kills / Destruction : "+str GAMEKILL+" / "+str GAMEMONEY+""; ctrlSetText [1002, _say];
};

 

So far all of the buttons are working properly and the bfSize slider is working as planned, but the time limit and score sliders are not displaying properly. I haven't started on the group number slider codes yet though.

Share this post


Link to post
Share on other sites

Huh??? What is 5? Nothing. Unless I am missing something? Did you try without?

On 2/21/2019 at 12:32 AM, HazJ said:

onSliderPosChanged

You pass 5 as an argument.

_select 0 - _control

_select 1 - _newValue

Your control IDC is 1904, it wants the control, not IDC.

You are overwriting it with 5. Remove it.


onSliderPosChanged = "0 = [] execVM 'settings\bfMenu1.sqf';";

 

 

Share this post


Link to post
Share on other sites

Here you go:

https://hazjohnson.com/ArmA/slider.VR.zip

Please learn from it.

bfMenu1Begin.sqf:

sliderSetRange [100, 5, 121];
sliderSetSpeed [100, 1, 10];
sliderSetPosition [100, gameTime];

_text = if !(gameTime isEqualTo 121) then {format ["Time remaining: %1 minutes", gameTime]} else {"Time remaining: Unlimited"};

ctrlSetText [200, _text];

((uiNamespace getVariable "sliderExample") displayCtrl 100) ctrlAddEventHandler ["SliderPosChanged",
{
	params ["_control", "_newValue"];
	gameTime = round _newValue;
	hintSilent str _this;
	_text = if !(gameTime isEqualTo 121) then {format ["Time remaining: %1 minutes", gameTime]} else {"Time remaining: Unlimited"};
	ctrlSetText [200, _text];
}];

(uiNamespace getVariable "sliderExample") displayAddEventHandler ["Unload",
{
	params ["_display", "_exitCode"];
	publicVariable "gameTime"; // only update across network upon closing
}];

Used your control values from above. Changed IDCs for my sake. Used latest GUI defines 1.88 (thanks to Larrow). Preview example mission.

Share this post


Link to post
Share on other sites
15 hours ago, HazJ said:

Huh??? What is 5? Nothing. Unless I am missing something?

Its their own index of what to do in the script when that particular sliders position is changed.

They are overwriting nothing, just because they do not use the ctrl as supplied by the event, there is nothing particularly wrong with doing it this way, although it could be handled differently.

Quote

onSliderPosChanged = "nul=[5]execVM'settings\bfMenu1.sqf';";

bfMenu1.sqf


 _sb=_this select 0; //passed index

//timeLimit slider;
if(_sb==5)then{ ///if index
	//Do something with slider
    GAMETIME=(floor (sliderPosition 1904)); _say="Time Limit : "+str GAMETIME+" Minutes"; if(GAMETIME==121)then{_say="No Time Limit";}; ctrlSetText [1005,_say];
}; 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Oh. I don't usually do it that way ha. It looks all weird to read. I provided an alternative solution anyway. I also thought it would of been select 3. For some reason. Brain must of been confused. 😀

Share this post


Link to post
Share on other sites
21 hours ago, HazJ said:

Here you go:

https://hazjohnson.com/ArmA/slider.VR.zip

Please learn from it.

It didn't work at first with just the code in bfMenu1Begin.sqf, but I copied your base_defines.hpp to my defines.hpp and now everything is working as planned! Thanks for the help!

Share this post


Link to post
Share on other sites

Yes, download the example mission to test it. Review code, learn from it and adapt to yours. Your original code was giving me headache lol ha so just re-did it. 😀

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

×