This snippet updates an array.
I.E:
You have an integer "Integer" with an array of 5.
Integer[0] = 0;
Integer[1] = 1;
Integer[2] = 2;
Up to 5.
Now, what if that variable was, say, a unit?
Unit variable with 1 dimension of 2.
Unit[0] = Zergling;
Unit[1] = Zealot;
Unit[2] = Marine;
Now say Unit[0] is the top dog, the unit with the most kills or whatnot. Now, when this unit dies, Unit[1] becomes top dog, and so on.
That is exactly what this snippet does.
Unit[0] = Unit[1]
Unit[1] = Unit[2]
And so on..
Also, the advantage of this to simply using Unit[0] = Unit[1] (Etc.) is that some maps have arrays of up to 500! Not only it would take a week to code, It would lag like crazy.
MoveUpArrayTestEventsTimer-Elapsedtimeis0.1GameTimesecondsLocalVariablesConditionsActionsTrigger-Add(Actions)totheactionqueueActionsUI-Display(Text(Integer[0]))for(Allplayers)toSubtitleareaVariable-SetVarMax=5-------SetXtothearraynumberthatisnownull--------------Startsfromarray0.Ifyouwantittostartfrom1,setthe"1"belowthiscommenttoa2.--------------Tonullifythevariable,goto"Variable - Set Integer[VarMax]"andthentopresets,andfinallyto"No Unit","None",ortherespectivenullvalueforthevariable.-------General-ForeachintegerIfrom1toVarMaxwithincrement1,do(Actions)ActionsVariable-SetInteger[(I-1)]=Integer[I]General-If(Conditions)thendomultiple(Actions)IfThenElseGeneral-Elseif(Conditions)thendo(Actions)ElseIfI==VarMaxThenVariable-SetInteger[VarMax]=NoneVariable-SetUnit=NoUnitUI-Display(Text(Integer[0]))for(Allplayers)toSubtitlearea
This works as intended, i have a seperate trigger set up the Integer variables like so:
Integer[0] = 0;
Integer[1] = 1;
Integer[2] = 2;
Integer[3] = 3;
Integer[4] = 4;
Integer[5] = 5;
The trigger first displays Zero (Before the array update), then it displays 1.
The trigger also removes Integer[5], since it is essentially Integer[4] now.
I don't think I need to upload an actual map for this, as it's snap coding, I can on request, however.
This snippet updates an array.
I.E:
You have an integer "Integer" with an array of 5.
Integer[0] = 0;
Integer[1] = 1;
Integer[2] = 2;
Up to 5.
Now, what if that variable was, say, a unit?
Unit variable with 1 dimension of 2.
Unit[0] = Zergling;
Unit[1] = Zealot;
Unit[2] = Marine;
Now say Unit[0] is the top dog, the unit with the most kills or whatnot. Now, when this unit dies, Unit[1] becomes top dog, and so on.
That is exactly what this snippet does.
Unit[0] = Unit[1]
Unit[1] = Unit[2]
And so on..
Also, the advantage of this to simply using Unit[0] = Unit[1] (Etc.) is that some maps have arrays of up to 500! Not only it would take a week to code, It would lag like crazy.
This works as intended, i have a seperate trigger set up the Integer variables like so:
Integer[0] = 0;
Integer[1] = 1;
Integer[2] = 2;
Integer[3] = 3;
Integer[4] = 4;
Integer[5] = 5;
The trigger first displays Zero (Before the array update), then it displays 1.
The trigger also removes Integer[5], since it is essentially Integer[4] now.
I don't think I need to upload an actual map for this, as it's snap coding, I can on request, however.