Jump to content
Ramsen II

2 questions: Waypoint & Arrays (non related)

Recommended Posts

Firstly I do not understand the need for the "unchanged" and "no change" when scripting waypoints? What are they for? whats the difference between:

 

Quote

_wp1 = grp1 addWaypoint [(getMarkerPos "mark1"),0];

_wp1 setWaypointType "MOVE";
_wp1 setWaypointBehaviour "AWARE";
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointCombatMode "YELLOW";
_wp1 setWaypointFormation "DIAMOND";#

 

_wp2 = grp1 addWaypoint [(getMarkerPos "mark2",0];

_wp2 setWaypointType "MOVE";
_wp2 setWaypointBehaviour "UNCHANGED";
_wp2 setWaypointSpeed "UNCHANGED";
_wp2 setWaypointCombatMode "NO CHANGE";
_wp2 setWaypointFormation "NO CHANGE";#

 

and....

 

Quote

_wp1 = grp1 addWaypoint [(getMarkerPos "mark1"),0];

_wp1 setWaypointType "MOVE";
_wp1 setWaypointBehaviour "AWARE";
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointCombatMode "YELLOW";
_wp1 setWaypointFormation "DIAMOND";#

 

_wp2 = grp1 addWaypoint [(getMarkerPos "mark2",0];

_wp2 setWaypointType "MOVE";

 

whats the difference?

 

2nd question:

 

How do i cycle the next element in an array each time i use, for example, add action "click"?

 

_array [one,two,three];

 

player addaction ["click" { ????}];

 

So when i activate action "click" first time it hints "one", then when i activate it a second time it says "two" and so on.

 

ForEach does not seem to be the answer as it does all three at once every time i activate "click". I need the array to cycle every time i select click?

 

The "click" is an example what i want is to cycle camera channels on one TV, see code below the "camera select" part, at the moment i have to set each camera using a variable as a switch...

 

Any help appreciated. thx ;)

 

Quote

b = 0;
therm = 0;

cam = "camera" camCreate [0,0,0]; // need this null camera as it prevents error when starting + deleting old camera and reloading new one.

 

player addaction ["Vision Mode",

 

    {

 

    if (therm == 0) then

 

        {

 

        "un1rtt" setPiPEffect [0];

 

        ["<t color= '#00ff00' size = '.8' >Vision Mode OFF</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;

 

        };

 

    if (therm == 1) then

 

        {

 

        "un1rtt" setPiPEffect [1];

 

        ["<t color= '#00ff00' size = '.8' >Night Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;

 

        };

 

    if (therm == 2) then

 

        {

 

        "un1rtt" setPiPEffect [2];

 

        ["<t color= '#00ff00' size = '.8' >Thermal Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;


        };

 

    if (therm == 2) then

 

        {

 

        therm = 0;

 

        }

 

        else

 

        {

 

        therm = therm + 1;

 

        };

 

    }];

 

player addAction ["Camera Select",

 

    {

 

    if (b == 0) then

 

        {

 

        cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive team1) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]};

        _bb = tv5;
        _bb setObjectTexture [0, "#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = team1;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

        ["<t color= '#ff0000' size = '.8' >Charlie Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;

 

        };

 

    if (b == 1) then

 

        {

 

        cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive team2) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]};

        _bb = tv5;
        _bb setObjectTexture [0, "#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = team2;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

        ["<t color= '#ff0000' size = '.8' >Alpha Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;

 

        };

 

    if (b == 2) then

 

        {

 

        cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive team3) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]};

        _bb = tv5;
        _bb setObjectTexture [0, "#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = team3;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

        ["<t color= '#ff0000' size = '.8' >Bravo Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText;

 

        };

 

    if (b == 2) then

 

        {

 

        b = 0;

 

        }

 

        else

 

        {

 

        b = b + 1;

 

        };

    }

];

 

 

Share this post


Link to post
Share on other sites

1. My guess would be that using "UNCHANGED" with waypoints is not necessary, and is mostly there for editor-placed waypoints, though I have never really had the need to script waypoints, so I could be wrong on that one.

2. I can't think a script command that will move the first element of an array to the back of the array, so a simple way of doing it would be something like this:

myArray = ["A", "B", "C"]; 
_selection = myArray select 0;
myArray = myArray - [_selection] + [_selection];
//Returns myArray as ["B", "C", "A"];

Not sure if that helps you at all.

Share this post


Link to post
Share on other sites

thx for helping again rebel.

 

I think you have got it but i am not sure how to implement it in my script.

 

ive highlighted in bold the areas so you get an idea what i'm looking for.

 

Quote

myarray = ["team1","team2","team3"];

 

player addAction ["Camera Select",

    {

         cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive myarray select 0;) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]};

        _bb = tv5;
        _bb setObjectTexture [0, "#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = myarray select 0;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

        _selection = myArray select 0;

        myArray = myArray - [_selection] + [_selection]; // at the end i add your script that now pushes the array along one, so when i "Camera Select" next time i will get the next element in the array (or next teams camera!)

}];

 

I get a type 'string expected object error' at the moment, but i think we are close! any advice how to fix ?

 

cheers again.

 

Share this post


Link to post
Share on other sites

What exactly do "team1", "team2", and "team3" refer to? Also, just as a side note, I would recommend not using myArray as a variable name in your script, as it doesn't provide any indication as to what the variable is for.

Share this post


Link to post
Share on other sites

That's a good point.

 

He's saying:

if (! alive <string>) then {
    bla bla bla
};

 

Obv, string isn't an object so it's a fail.

 

@OP  "team1" is a string.  You need to be referencing some objects

_grp = grp player;

_aUnitProbablyThePlayer = _grp select 0;

if (_aUnitProbablyThePlayer isEqualType  "someString") then {
     systemChat "not going to happen" // hopefully never going to see this code
} else {
     if (_aUnitProbablyThePlayer isEqualType objNull) then {
         systemChat "yes you are an object";
         if (_aUnitProbablyThePlayer isKindOf "CaManBase") then {
            systemChat "yes you exist and are a man!"
         };
    }
};

 

 

 

Share this post


Link to post
Share on other sites

As to your second question there's a simple solution:

//define global array to test:
testArray = [1,2,3];

//basic functionality:
current = testArray select 0;
testArray pushBack current;
testArray deleteAt 0;
systemchat format ["Activated %1",current];

//as addAction:
player addAction ["Who is next in line?",{

current = testArray select 0;
testArray pushBack current;
testArray deleteAt 0;
systemchat format ["Number %1 is next in line!",current];

}];

Cheers

Share this post


Link to post
Share on other sites

Just...

current = testArray deleteAt 0;
testArray pushBack current;

DeleteAt returns the deleted element. Ready to be pushed to the end of the array.

Could even be shortened to

testArray pushBack ( testArray deleteAt 0 );
h = [] spawn {
	testArray = [ "A", "B", "C", "D", "E", "F", "G" ];
	while { true } do {
		current = testArray select ( testArray pushBack ( testArray deleteAt 0 ));
		hint format[ "%1\n%2", testArray, current ];
		sleep 1;
	};
};

 

  • Like 1

Share this post


Link to post
Share on other sites

haha lots of discussion over my below par scripting!! ;D

 

I should have been clearer. I made the mistake putting team1, team2 ect in quotations they are each referring to the leader of the group, confusing i know i should have named them unit1, unit2 etc because i am referring to units.

 

What i am doing is creating a shoulder cam on the first unit (and it shows up on a screen named tv5) when i select the addaction - 'Change Camera' command. But i want to cycle between teams, going unit1, unit2, unit3 then back to unit1 every-time i select 'Change Camera'. (In my case they are named team1, team2, team3 so the array will be named:  _units = [team1,team2,team3];

 

The long explanation:

At the moment i have it working where i create the script three times using a makeshift switch using variable (b =  0 to begin with) So when i select the first cam - {if b = 0 then (code creates cam on first unit) ... end the code with b = b + 1. (so now b = 1) so next time i change camera (if b = 1 then it destroys the old camera and creates new cam on the second unit. Same for third but here i reset the switch ( if b = 2 then b = 0 again so next time i change camera im back on team 1 bla bla bla bla....  ) this works fine but i don't learn anything i know there's an advanced but more efficient way of doing this.

 

p.s also i do same for vision mode (therm = 0) i have 'Cam Mode' where i can switch between night vis, thermal and normal visions of the units camera that i am watching. Works well and is actually really fun when playing as High Command and you can watch your teams on screen. Also i add a custom 'static' texture to tv5 if the unit in question dies.

 

Anyhow I will test out all ur suggestions later on. I did look up pushBack and Select + more on arrays but it's still a little advanced for me. but i will get there.

 

Thx again for all you help ;)

Share this post


Link to post
Share on other sites

success. thx too all for helping, but grumpy + larrow script works perfectly i knew it had something to do with PushBack but i couldn't figure it out. Anyway here's the finished working script:

 

Quote

cam = objNull;
leadunits = [unit1,unit2,unit3];
vismode = [0,1,2];

player addAction ["Camera Select",

    {

        current = leadunits select (leadunits pushBack (leadunits deleteAt 0)); // the piece of code i was looking for!! ;)

        cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive current) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]};

        _bb = tv5;
        _bb setObjectTexture [0,"#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = current;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

        if (current == unit3) then {["<t color= '#ff0000' size = '.8' >Charlie Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        if (current == unit2) then {["<t color= '#ff0000' size = '.8' >Bravo Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        if (current == unit1) then {["<t color= '#ff0000' size = '.8' >Alpha Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};

    }

];


player addaction ["Vision Mode",

    {
        currentvis = vismode select (vismode pushBack (vismode deleteAt 0));

        "un1rtt" setPiPEffect [currentvis];

        if (currentvis == 0) then {["<t color= '#00ff00' size = '.8' >Vision Mode OFF</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        if (currentvis == 1) then {["<t color= '#00ff00' size = '.8' >Night Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        if (currentvis == 2) then {["<t color= '#00ff00' size = '.8' >Thermal Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};

    }

];

 

works a treat. ;)

Share this post


Link to post
Share on other sites

You could also use a switch rather than a bunch of If-Then statements. Something along the lines of:
 

switch (currentvis) do {
	case 0: {["<t color= '#00ff00' size = '.8' >Vision Mode OFF</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
	case 1: {["<t color= '#00ff00' size = '.8' >Night Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
	case 2: {["<t color= '#00ff00' size = '.8' >Thermal Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
	default {hint format ["%1 is not a valled argument for currentvis!", currentvis]};
};

 

Edited by rebel12340
Fixed code.

Share this post


Link to post
Share on other sites

thx for suggestion.

 

I cannot seem to get the addaction working with the switch code in there?

 

where do i put the switch code and how does it know which mode / unit im on (sorry im unfamiliar with 'switch' and 'case')

 

cheers.

 

p.s Also you put the wrong bracket end of format text! ;-) should be a ]

p.p.s what is the default and hint bit for also??

 

No worries got it working. ;) missed a bracket.

Share this post


Link to post
Share on other sites

o.k thx to rebel suggestion - here is my final final camera switching script for you all to enjoy!! ;D

 

Quote

cam = objNull;
leadunits = [unit1,unit2,unit3];
vismode = [0,1,2];

player addAction ["Camera Select",

    {

        current = leadunits select (leadunits pushBack (leadunits deleteAt 0));

        switch (current) do

        {

        case unit1: {["<t color= '#ff0000' size = '.8' >Alpha Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        case unit2: {["<t color= '#ff0000' size = '.8' >Bravo Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        case unit3: {["<t color= '#ff0000' size = '.8' >Charlie Recon</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        default {hint format ["%1 is not a valid argument for current!", current]};

        };

        cam cameraEffect ["terminate","back"];
        camDestroy cam;

        if (!alive current) exitwith {tv5 setObjectTexture [0, "textures\static1.paa"]}; // If anyone else uses this script make sure to delete this line or choose your own custom texture!

        _bb = tv5;
        _bb setObjectTexture [0,"#(argb,512,512,1)r2t(un1rtt,1)"];

        _un = current;
        _un lockCameraTo [_bb, [0]];

        cam = "camera" camCreate [0,0,0];
        cam cameraEffect ["Internal", "Back", "un1rtt"];
        cam attachTo [_un, [0.6,0,0.2], "neck"];
        cam camSetFov 0.75;

        "un1rtt" setPiPEffect [1];

    }

];


player addaction ["Vision Mode",

    {
        currentvis = vismode select (vismode pushBack (vismode deleteAt 0));

        "un1rtt" setPiPEffect [currentvis];

        switch (currentvis) do

        {

        case 0: {["<t color= '#00ff00' size = '.8' >Vision Mode OFF</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        case 1: {["<t color= '#00ff00' size = '.8' >Night Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        case 2: {["<t color= '#00ff00' size = '.8' >Thermal Vision</t>",-1,-1,1,0,0,001] spawn BIS_fnc_dynamicText};
        default {hint format ["%1 is not a valid argument for currentvis!", currentvis]};

        };


    }

];

 

Share this post


Link to post
Share on other sites

I take it you got it working, then? Good to know. The point of the default hint is so that if you pass an argument into the switch that doesn't match one of the cases (such as setting currentVis to 3) it will show a hint on your screen that says "3 is not a valid argument for currentvis!".

Share this post


Link to post
Share on other sites

yeah i worked out it was for debugging when i accidentally used case 0, case 1, etc for the units!! so i changed it to case unit1, case unit2. 

 

anyhow thx again for your help! has been just one long scripting lesson for me tonight! lol

 

cheers.

Share this post


Link to post
Share on other sites

You could also store the dynamic text alongside the units/mode each in their own array, then use params to retrieve the info. Saves switching or multiple if statements.

You can also get Arma to create a static texture for you using procedural textures.

Spoiler

cam = objNull;
leadunits = [
	[ unit1, "Alpha Recon" ],
	[ unit2, "Bravo Recon" ],
	[ unit3, "Charlie Recon" ]
];
vismode = [
	[ 0, "Vision Mode OFF" ],
	[ 1, "Night Vision" ],
	[ 2, "Thermal Vision" ]
];

player addAction ["Camera Select", {

	leadunits select (leadunits pushBack (leadunits deleteAt 0)) params[ "_unit", "_text" ];

	[ format[ "<t color= '#ff0000' size = '.8' >%1</t>", _text ], -1,-1,1,0,0,001 ] spawn BIS_fnc_dynamicText;
	cam cameraEffect ["terminate","back"];
	camDestroy cam;

	if (!alive _unit) then {
		tv5 setObjectTexture [0, "#(ai,512,512,1)perlinNoise(512,512,0,1)"];
	}else{
		tv5 setObjectTexture [0,"#(argb,512,512,1)r2t(un1rtt,1)"];
    	
		_unit lockCameraTo [ tv5, [0]];
    	
		cam = "camera" camCreate [0,0,0];
		cam cameraEffect ["Internal", "Back", "un1rtt"];
		cam attachTo [_unit, [0.6,0,0.2], "neck"];
		cam camSetFov 0.75;
    	
		"un1rtt" setPiPEffect [1];
	};

}];


player addAction [ "Vision Mode", {
	vismode select (vismode pushBack (vismode deleteAt 0)) params[ "_mode", "_text" ];

	"un1rtt" setPiPEffect [_mode];
	[ format[ "<t color= '#00ff00' size = '.8' >%1</t>", _text ], -1,-1,1,0,0,001 ] spawn BIS_fnc_dynamicText;

}];

 

 

Share this post


Link to post
Share on other sites

Nice 1 larrow, especially the static effect didn't even know you could do that + never heard of procedural textures!?

 

looks like a proper script now + strange actually, how its evolved compared to my early version!

 

cheers everyone.

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

×