How to GET Current Array Element [solved]

if i have table B

B[0]=1;2;3
B[1]=5;6;7

and that below its true

{
Is True For Any(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, 8)) == True;
}

then how can i get Current Array Element
and save it in var. A

You can use the same compare statement in a filtered array, and set global variable A equal to that filtered array. Now, if the filtered array simply produces one value, then global variable A will equal just that one value. If there are multiple values, then A will equal the resulting filtered array (but A itself will not be a filtered array after the assignment).

my english is not as good as i want to be.

and scripting it’s not equal to programming,
i don’t understand many things

so, can i have the CODE ?
please.

Give me some time to write up an example.

rule(“Example”)
{
event
{
Ongoing - Global;
}

conditions
{
	Is True For Any(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, 8)) == True;
}

actions
{
	Set Global Variable(A, Filtered Array(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, 8)));
}

}

1 Like

Do you understand the code above?

Also, “filtered array()” gives you all areas the player is inside, while “first of(sorted array())” gives you only the closest of the areas to the player. Depends on what you need.

1 Like

This may works, but you need to have to known that when condition is evulated you can have different values in action, since workshop evulate conditions, after evulate actions.

Yes i understand that, than you.

Yes, but usually that is neligible. The moment the condition is true, the next frame the action is executed.

ok, i have another question.

it is possible to have condition true with different range size.
here i have allways radius 8

B[0] = 1;2;3
B[1] = 4;5;6
Is True For Any(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, 8)) == True;

C[0] = 8
C[1] = 4

Is True For Any(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, Index Of Array Value(Global Variable( C), Current Array Element))) == True;

Change it to: Is True For Any(Global Variable(B), Compare(Distance Between(Position Of(Event Player), Current Array Element), <=, value in array(global variable(C), Index Of Array Value(Global Variable(B), Current Array Element)))) == True;
Then it should work fine.