separate it to two separate for each loops maybe?
This results in very bad procedural coupling. You are basically creating a completely duplicate block of code. Not only does this make maintenances more hard but also wastes space. Both the solutions above will perform similarly but with the advantage that you only have 1 block of code.I think you'll just have to do two separate loops in the same trigger, but not in each other.
For each integer loop_var from 2 to 5 do actions
Loop (actions)
Set variable[loop_var] = something
Set variable[loop_var + 6] = something else
Would require declaring the code in a function (not supported in GUI, slower in any case due to JASS being rubbish) to avoid procedural coupling.This way, you end up with 2-5 indexes for variable set in the first line, and indexes 8-11 set in the second action.
JASS is not a functional language so it does not support map operations.Don't use a loop and go through all index 1 by 1.
Array list is faster. Use one to define a mapping from 0 to 7 to 2 to 5 and 8 to 11.
The array list will look like...
SlotMap[0] = 2
SlotMap[1] = 3
SlotMap[2] = 4
SlotMap[3] = 5
SlotMap[4] = 8
SlotMap[5] = 9
SlotMap[6] = 10
SlotMap[7] = 11
SlotMapMax = 12
Then all you need to do is loop from 0 to 7 and use that loop integer as the index to SlotMax to get your value. This is probably the most efficient way as it avoids tests.
Put this somewhere at map initialization.Please post an example? Because I am confused.
Avoids unnescescary tests in exchange for array lookups. In JASS with this scale of numbers it is questionable if it is faster or slower however in GUI since conditional tests are horribly slow due to separate function calls they require it will be noticeably faster.And how would that be any better than this:
Yes so you check from 0 to 7 (or is GUI so retarded it forces you to use 1 as the start index?).Because that's checking between 1-8, and 0 isn't included???
Yes so you check from 0 to 7 (or is GUI so retarded it forces you to use 1 as the start index?).
Logically? No.No, you can set it to 0, but all I am asking is...is there anything wrong with me starting with 1 and not using 0?
Logically? No.
Technically? Yes.
It will work but you equivalently waste index 0. This is unlikely to make much of a difference in JASS as arrays expand in powers of two (so the array is probably larger than you need anyway, the difference would be around critical values) but in languages like C, C++ or Java it would waste an extra array element size worth of memory.