for..to..do loops are very efficient to use.
They're especially useful for tasks such as cleaning herbs, where you have to click each and every inventory slot.
is what you'll see in most cases (if regarding the inventory).
This'll be very short, but simple guide on how to use them.
Take my scatterer script's Scatter procedure -
Simba Code:
procedure Scatter;
var
i:Integer;
begin
MouseSpeed := 255;
MouseItem(1,1);
MouseItem(5,1);
MouseItem(9,1);
MouseItem(13,1);
MouseItem(17,1);
MouseItem(21,1);
MouseItem(25,1);
MouseSpeed := 18;
MouseItem(2,1);
MouseSpeed := 255;
MouseItem(6,1);
MouseItem(10,1);
MouseItem(14,1);
MouseItem(18,1);
MouseItem(22,1);
MouseItem(26,1);
MouseSpeed := 18;
MouseItem(3,1);
MouseSpeed := 255;
MouseItem(7,1);
MouseItem(11,1);
MouseItem(15,1);
MouseItem(19,1);
MouseItem(23,1);
MouseItem(27,1);
MouseSpeed := 18;
MouseItem(4,1);
MouseSpeed := 255;
MouseItem(8,1);
MouseItem(12,1);
MouseItem(16,1);
MouseItem(20,1);
MouseItem(24,1);
MouseItem(28,1);
end;
What happens in that procedure is, it'll click each an every inventory slot at VERY high speeds, and its natural for some of the clicks to not go through.
What we can add at the end of the procedure is -
Simba Code:
repeat
for i := 1 to 28 do
begin
if ExistsItem(i) then
MouseItem(i,1);
end;
Until(InvEmpty);
What that'll do is it'll cycle through i, which is an array of sorts of 1 to 28.
If an item exists in *i*, then it'll click it.
Test it out, play around with it, it'll come in real useful one day.
Sorry if you can't understand it, it's 11PM here and I was awake the whole day starting from 5AM ;s