Array question

Hi guys

I’ve got this piece of code:

  
local function myFunction()   
  
local m  
  
for m=1, #myObjects, 1 do  
  
 -- do stuff  
  
end  
end  

I would like to increase the value of another variable but only once the last object in the array has been processed.

I’ve tried but it increases the value on every object.

What’s the best way to do this? [import]uid: 40538 topic_id: 14013 reply_id: 314013[/import]

[code]
local function myFunction()

local m

for m=1, #myObjects, 1 do

– do stuff

end
– just put it outside the loop.
variableToIncrease = variableToIncrease + 1
– if its the last array item that needs updated
– myObjects[#myObjects].varaibleToIncrease = myObjects[#myObjects].varaibleToIncrease + 1
end
[/code] [import]uid: 19626 topic_id: 14013 reply_id: 51600[/import]

Sorry, I didn’t mention that the function is in a Runtime EventListener, so is constantly being checked.

Putting it outside the loop constantly updates it.

Is there anyway to do this?

I know it’s not optimal, but I don’t mind hard coding the values. [import]uid: 40538 topic_id: 14013 reply_id: 51609[/import]

what is the condition to be met before increasing the value of that variable ?
" only once the last object in the array has been processed"
are you not processing all the values in the array inside the function itself ?
does that array adds new values on each event ticks ?

[import]uid: 71210 topic_id: 14013 reply_id: 51675[/import]