get Index from 2 arrays simultaneously?
-
Why are you storing value in a local array?
local myArray; myArray = Maps[value]; //set the sample map list based on the category Viewport2.set("items",myArray.join("\n"));
-
Like i said, i need help, im at loss what to do..
Tried so many things.. -
@ten7kur said in get Index from 2 arrays simultaneously?:
Like i said, i need help, im at loss what to do..
Tried so many things..If you could point the right direction id really appreciate it!!
-
Could you reword the question because I'm still not clear what you're trying to do. The thread title is
get Index from 2 arrays simultaneously?
but then your post is talking about viewports. -
@d-healey said in get Index from 2 arrays simultaneously?:
Could you reword the question because I'm still not clear what you're trying to do. The thread title is
get Index from 2 arrays simultaneously?
but then your post is talking about viewports.The last part of the script: @line49
inline function onViewport2Control(component, value) {
Im trying to get 2 variables to say = yes
(inside the inline_function)
I cant get it to work -
This post is deleted! -
@d-healey said in get Index from 2 arrays simultaneously?:
Maps doesn't exist inside this function.
thats what i thought.
How can i get at it?EDIT: precisely , how can i access a variable outside the inline function?
-
@ten7kur You commented faster than I could delete my post :p
-
I think this is where the problem is.
var Item1 = ["Item1A","Item1B","Item1C"]; var Item2 = ["Item2A","Item2B"]; var Maps = [Item1, Item2];
This is what maps contains
[ [ "Item1A", "Item1B", "Item1C" ], [ "Item2A", "Item2B" ] ]
Is that what you want?
-
hmm
Im trying to get the index of both arrays.
The INDEX of var Item1 and then the INDEX of Item1A, Item1b, Item1C.So if var Item1 is true AND var Item1A is true, i can do something.
-
@ten7kur getting an INDEX of an item in an array? will return you a position in the array - not a true/false answer (well apart from the first two ..)
your code says;
if (Maps[value] == 0 && value == 0)
where Maps[value] will always = another array , not zero...
-
@Lindon said in get Index from 2 arrays simultaneously?:
@ten7kur getting an INDEX of an item in an array? will return you a position in the array - not a true/false answer (well apart from the first two ..)
your code says;
if (Maps[value] == 0 && value == 0)
where Maps[value] will = another array , not zero...
Buts thats what i want, is the Position in the array. Then i can do a true/false if. Dont i? Ive tried everyting(as in my first post described)
All credit to @lindon , thats where this code comes from -
@ten7kur OK look this code:
inline function onViewport2Control(component, value) { SelectedItemName.set("text",Maps[Viewport1.getValue()][value]); //print selection Index Console.print("selected:" + value); // if both Indexs are correct, then print "OK-selected" if (Maps[value] == 0 && value == 0) { local Selection = "OK-selected"; Console.print("selecton:" + Selection); } }; Content.getComponent("Viewport2").setControlCallback(onViewport2Control);
Just put this line in there:
Console.print(Maps[value]);
and you will see you are getting an array back.... not a value.
So this:if (Maps[value] == 0)
will NEVER be true...
What are you trying to do?
-
I dont know how much easier i can explain.
I wish to do:
If the index of Vieport1 and index of Viewport2 = to what i want, then do........somethng ,eg print console -
@Lindon said in get Index from 2 arrays simultaneously?:
@ten7kur OK look this code:
inline function onViewport2Control(component, value) { SelectedItemName.set("text",Maps[Viewport1.getValue()][value]); //print selection Index Console.print("selected:" + value); // if both Indexs are correct, then print "OK-selected" if (Maps[value] == 0 && value == 0) { local Selection = "OK-selected"; Console.print("selecton:" + Selection); } }; Content.getComponent("Viewport2").setControlCallback(onViewport2Control);
Just put this line in there:
Console.print(Maps[value]);
and you will see you are getting an array back.... not a value.
So this:if (Maps[value] == 0)
will NEVER be true...
What are you trying to do?
Yes that works, but i need 2 variables to = True
-
@ten7kur WHICH TWO VARIABLES!!!
-
@Lindon said in [get Index from 2 arrays simultaneously?]
What are you trying to do?
trying to pass another variable if both = to True
-
@ten7kur both what are equal true? There is NO "True" inside the array
there is no way that Maps[any value here] will EVER = true.
it can only ever = the contents of one of the array slots or undefined.
-
@Lindon said in get Index from 2 arrays simultaneously?:
WO VARIABLES!!!
So thats my question.
I need to have a True to both items.
var Maps. and the Viewport2 valueuhh this is heavy
-
@Lindon said in get Index from 2 arrays simultaneously?:
@ten7kur both what are equal true? There is NO "True" inside the array
there is no way that Maps[any value here] will EVER = true.
it can only ever = the contents of one of the array slots or undefined.
Then to "Item1"?
This cant be impossible