int barrelcount() { int count = 0; for x from 8568 to 8577 { count += item_amount( to_item( x ) ); } return count; } for x from 8568 to 8577 { if ( item_amount( to_item( x ) ) > 0 ) { visit_url( "inv_use.php?pwd&whichitem=" + x + "&choice=1" ); break; } } while ( barrelcount() > 0 ) { run_choice( 2 ); }