prontera,152,188,5 script test getitemname2 100,{
getinventorylist;
dispbottom "No sort === Total items : "+ @inventorylist_count +" ===";
.@i = 0;
while ( .@i < @inventorylist_count ) {
.@itemname$ = callfunc("getitemname2", @inventorylist_id[.@i], @inventorylist_identify[.@i], @inventorylist_refine[.@i], @inventorylist_attribute[.@i], @inventorylist_card1[.@i], @inventorylist_card2[.@i], @inventorylist_card3[.@i], @inventorylist_card4[.@i]);
dispbottom "("+ @inventorylist_id[.@i] +") "+ .@itemname$ +": "+ @inventorylist_amount[.@i] +" ea." + @inventorylist_identify[.@i] +" "+ @inventorylist_attribute[.@i];
.@i++;
}
end;
}
prontera,155,188,5 script getitemname2 ID sorted 100,{
freeloop 1;
getinventorylist;
dispbottom "Comb sort === Total items : "+ @inventorylist_count +" ===";
callfunc "comb_sort", @inventorylist_id, .@output, @inventorylist_count;
.@i = 0;
while ( .@i < @inventorylist_count ) {
// dispbottom @inventorylist_id[ .@output[.@i] ] +"";
.@itemname$ = callfunc("getitemname2", @inventorylist_id[ .@output[.@i] ], @inventorylist_identify[ .@output[.@i] ], @inventorylist_refine[ .@output[.@i] ], @inventorylist_attribute[ .@output[.@i] ], @inventorylist_card1[ .@output[.@i] ], @inventorylist_card2[ .@output[.@i] ], @inventorylist_card3[ .@output[.@i] ], @inventorylist_card4[ .@output[.@i] ]);
dispbottom "("+ @inventorylist_id[ .@output[.@i] ] +") "+ .@itemname$ +": "+ @inventorylist_amount[ .@output[.@i] ] +" ea.";
.@i++;
}
end;
}
// callfunc "comb_sort", <input array>, <output index>, <total index>;
function script comb_sort {
while ( .@i < getarg(2) ) {
set .@arr[.@i], getelementofarray( getarg(0), .@i );
set getelementofarray( getarg(1), .@i ), .@i; // note : I'm generating a dummy index here, so this one will be output as the sorted index later
.@i++;
}
.@size = .@gap = getarg(2);
do {
if ( .@gap > 1 )
.@gap = .@gap * 10 / 13;
.@i = .@swap = 0;
while ( .@i + .@gap < .@size ) {
if ( .@arr[.@i] > .@arr[ .@i + .@gap ] ) {
.@tmp = .@arr[.@i];
.@arr[.@i] = .@arr[ .@i + .@gap ];
.@arr[ .@i + .@gap ] = .@tmp;
.@tmp = getelementofarray( getarg(1), .@i ); // dummy index is being swap here
set getelementofarray( getarg(1), .@i ), getelementofarray( getarg(1), .@i + .@gap );
set getelementofarray( getarg(1), .@i + .@gap ), .@tmp;
.@swap = 1;
}
.@i++;
}
} while ( .@swap || .@gap > 1 );
return;
}