BlobbieScript - Expressions - Foreach

The foreach construct enables easy iteration over an array's values. This simplifies the task of updating a series of items, mobiles, rooms, or anything else in an array.

    Example:

foreach( %roomGetMobiles() as @mob ) { // // Give a little regen bonus. // @mob->hitpoints += 2d3 } endwhile;
    Example (with index):

@mobiles = %roomGetMobiles() foreach( @mobiles as @index => @mob ) { // // Move to Elkin fountain. // %move( @mobiles->@index, 115611 ); } endwhile;