SRL Archive - Reflection Help

GroundItems + ChooseOption


blackfire553

2011-06-23 17:22:23

Im trying to pick up certain ground items, and this is what im doing:

  Players[0].Arrays[0] := ['Iron arrow','Bronze arrow','Tin ore','Copper ore','Rune','Coins','Bones'];
end;
procedure PickUpGroundItems;
var
ItemsOnGround : TGroundItemArray;
ItemPoint : TPoint;
i,j: integer;
begin
if not (LoggedIn) then
Exit;
ItemsOnGround := GetItemsNear(Players[CurrentPlayer].Integers[0]);
For i := 0 to high(ItemsOnGround) do
begin
if R_InvFull then
Exit;
ItemPoint := TileToMS(ItemsOnGround[i].Tile,0);
if (ItemPoint.x > 0) then
begin
Mouse(ItemPoint.x-3,ItemPoint.Y-3,0,0,false);
for j := 0 to high(Players[0].Arrays[0]) do
begin
writeln('Take ' + Players[0].Arrays[0][j]);
if ChooseOption('Take ' + Players[0].Arrays[0][j]) then
begin
//stats_IncVariable('Bones (Collected)',1);
writeln('Pickin shit up...');
wait(2500);
end;
end;
end;
end;
end;

It only picks up bones, but im sure im doing the capetalization right. Is there a better way to do this? How do i sort the array of ground items?

Rich

2011-06-23 18:31:47

Try it without the capital letters.

Eg "ronze arrows" (no B at all)

mormonman

2011-06-23 19:42:45

Use R_ChooseOption.

blackfire553

2011-06-23 21:50:51

From: Rich
Try it without the capital letters.

Eg "ronze arrows" (no B at all)


This has worked for me before, and i would use it, but i need to do 'Take ' + so it doesnt click examine. Thank you for the suggestion.

From: mormonman
Use R_ChooseOption.


Thank you

Smarter Child

2011-06-23 22:07:05

From: blackfire553
This has worked for me before, and i would use it, but i need to do 'Take ' + so it doesnt click examine. Thank you for the suggestion.



Thank you


Just a tip, you can always make a case so it will randomly right click -> choose pick up option, or left click. It can add to the randomness.

mormonman

2011-06-23 22:11:56

You also might want to break out of the second loop after it picks the item up, so that it goes onto the next item.

blackfire553

2011-06-24 03:03:31

This is what i have now:

procedure PickUpGroundItems;
var
ItemsOnGround : TGroundItemArray;
ItemPoint,MyPoint : TPoint;
ItemPoints : TPointArray;
i,itemsPickedUp: integer;
begin
itemsPickedUp := 0;
repeat
if not (LoggedIn) then
Exit;
if R_InvFull then
Exit;
ItemsOnGround := GetItemsNear(Players[CurrentPlayer].Integers[0]);
Me := GetMe();
MyPoint := TileToMS(Me.tile,230);
SetLength(ItemPoints,GetArrayLength(ItemsOnGround));
For i := 0 to GetArrayLength(ItemPoints)-1 do
begin
writeln(inttostr(ItemsOnGround[i].ID));
ItemPoints[i] := TileToMS(ItemsOnGround[i].Tile,0);
end;
SortTPAFrom(ItemPoints,MyPoint);
For i := 0 to GetArrayLength(ItemPoints)-1 do
begin
Mouse(ItemPoints[i].x-2,ItemPoints[i].y-2,0,0,false);
if R_ChooseOptionMulti(ItemsToPickup) then
begin
writeln('Got dat shit...');
wait(2500);
itemsPickedUp := itemsPickedUp + 1;
break;
end;
end;
until(itemsPickedUp = 10);
end;

Thanks for all your help!

Rich

2011-06-24 06:42:28

From: blackfire553
This is what i have now:


until(itemsPickedUp = 10);
end;
Where you have that, perhaps do a time check, so if it's been looking for over x second, then Exit. Also, instead of having a static number (10), maybe you could make that dynamic comparable to the amount of items found on the ground.

Smarter Child

2011-06-24 17:53:45

How about you change:
  until(itemsPickedUp = 10);
to
  until(itemsPickedUp >= 10);

Because who knows, the script might pick up say, 11 objects and the function would be just hanging there.