[solved] subtracting a value during a loop

So currently I am building a little same game and I am having a little trouble. I am trying to create a scaling difficulty. As the player scores I want the frequency of enemy spawn rates to increase. At the moment I have a variable called diifValue that represents this. Each time the player gets a frag/kill I want to subtract -1 off the diffValue variable. For now I just want to have it so over time it gets subtracted (while I coding the game I want to see how well it works) so I am going to put in the main game loop. I just wondered what the correct was of doing this was

(I cut some other code out just to make it easier to see)

[lua] local diffValue = 3000

local timeLastEnemy = 0

…loop start

    if event.time - timeLastEnemy >= math.random(diffValue, 5000) then

    local enemy = display.newImageRect( “crate.png”, 30, 30 )

    enemy.x, enemy.y = 550, math.random(20, 300)

    enemy.rotation = math.random (-90, 90)

    

                timeLastEnemy = event.time

…loop end

[/lua]

I originally had:

  [lua]  local diffValue = -1 [/lua]

but obviously that sets the diffValue where as I want to just -1 off the total value each pass of the loop. 

I don’t suppose anyone would know the correct way to do this? Thank you.

EDIT: I guess basically I am asking how do I subtract -1 off diffValue every loop pass, once I work that out I can just apply it to then if loop that will be the bullet collision.

SOLVED!

[lua]diffValue = diffValue - 1[/lua]

that did it.

SOLVED!

[lua]diffValue = diffValue - 1[/lua]

that did it.