Currently in order to decide if I want to add a value into the stack I have to do a condition to compare before the action to push the value.
That doubles the work, doubles the number of comparisons.
I want to do a comparison in the action, without having to add a value to the stack if the comparison comes up with a value I don't want to add.
Nothing is not an option. ha ha
To be more specific. I want to see if a value exists, before I add it, but theres two different values, x, and y, so two different arrays... as stacks.
Even more specific. The last value in the stack is what need to be compared.
Does it have to be done in the expression itself, or would it be okay to use a function (e.g "AddValue") that accepts the Array.UID as a param? This would involve adding all arrays you operate on to an ArrayFamily, and the function would pick the appropriate instance using the UID. It would definitely simplify your events on one end, but I'm not sure if that's what you're after.
Develop games in your browser. Powerful, performant & highly capable.
Its in a for loop, and the arrays are children in the container sprite.
I don't think a function can work in a loop, and they have no way to add nothing.
Of course you could do some conditional trickery and create a param that you don't use, but that ruins the use of the index.
I'm thinking a nested string in a variable may be the best solution.
Hmm, I don't quite follow. This is the way I'm envisioning the basic events if you used a function. What will not work here?
For "" from x to y:
-- Call "AddValue" (ArrayA.UID, ValueForA)
-- Call "AddValue" (ArrayB.UID, ValueForB)
-- Call "AddValue" (ArrayC.UID, ValueForC)
On "AddValue", Pick ArrayFamily by UID Function.Param(0)
-- If ArrayFamily.Back IS NOT EQUAL TO Function.Param(1)
I see now. Yes that will work, but I was hoping there was some way to do conditionals in the actions so I wouldn't have to add more conditions.
I think I found a little hack you could use
Array.Push(YourValue) // push a new element regardless of the comparison
Array.Delete(Array.At(Array.Width-2) = Array.At(Array.Width-1) ? Array.Width-1 : Array.Width) // compare and delete if need be
I might have screwed that up, but essentially you can exploit the fact that trying to delete an element outside of the array does NOTHING. So you can put your conditional in the delete event. If the comparison passes, use an index outside the array (so it won't delete anything). If it fails, then delete the element you just added by using the last index in the array.
That might work.