Sorry, but looks like a bad planned code.
You don't need the count_1 var.
Do you want the set_dust function running all the time?
If so, do you remove sprite in the DUST action with dust_num decrementing?
Code:

var dust_num=0;
action dust
{
while(!player){wait(1);}//wait for a player in the level
while(vec_dist(my.x, player.x)<500){wait(1);}//wait while player near me
dust_num -= 1;
ent_remove(me);
}
function set_dust()
{
while(1)
{
while(dust_num > 40) {wait(1);}//wait while no free places
temp.x=random(screen_size.x);
temp.y=random(screen_size.x);
temp.z=400+random(50);
vec_for_screen(temp.x, camera);
create(<dust1.bmp>, temp.x, dust);
dust_num += 1;
}
}


If no, for initial dust setup, You have not to use while(1) at all.
Code:

function set_dust()
{
while(dust_num < 40)
{
temp.x=random(screen_size.x);
temp.y=random(screen_size.x);
temp.z=400+random(50);
vec_for_screen(temp.x, camera);
create(<dust1.bmp>, temp.x, dust);
dust_num += 1;
}
}


P.S.
Search for a 'grass following the player', 'placing grass' or alike in the contrib or tut thread.