SRL Archive - OSR Help

Type Mismatch


DeSnob

2011-01-11 16:56:58

function FindRock: Boolean;
var
Rocks: TRSObjectArray;
begin
Rocks := GetObjectByID(Which, OBJECT_TYPE_INTERACTABLE, 15);<TROUBLE MAKER
R_FindRandoms;
if Length(Rocks) < 0 then
LogOut;
for i:= 0 to High(Rocks) do
begin
YRock := Rocks[i].Tile;
YRockID := Rocks[i].ID;
RockP := TileToMs(Rocks[i].Tile, 0);
MMouse(RockP.x, RockP.y, 5, 5);
Wait(100+random(230));
R_FindRandoms;
If IsUpText('ine') then
begin
GetMousePos(x, y);
Mouse(x, y, 1, 1, True);
Writeln('Clicked Rock');
Result := True;
Exit;
end;
end;
end;

Just trying to use my powerminer again, but I get this issue.

**BANNED The Man

2011-01-11 18:04:18

Do:
Rocks := GetObjectByID(Which, 0, 15);

and report back :)

-Boom

DeSnob

2011-01-11 18:41:12

From: Dynamite
Do:
Rocks := GetObjectByID(Which, 0, 15);

and report back :)

-Boom


I don't know why, but there is no difference. It was working perfectly a month ago, no idea whatsoever.

bugger0001

2011-01-11 19:05:10

Mate, wrong function…replace the troublemaker with this:
Rocks := GetObjectsByID(Which, OBJECT_TYPE_INTERACTABLE, 15);

**Notice the "s" in GetObjectsByID ;)

DeSnob

2011-01-11 21:07:02

From: bugger0001
Mate, wrong function…replace the troublemaker with this:
Rocks := GetObjectsByID(Which, OBJECT_TYPE_INTERACTABLE, 15);

**Notice the "s" in GetObjectsByID ;)


I've tried that too. However, it really is a function:
{*******************************************************************************
function GetObjectsByID(IDs: TIntegerArray; objType, MaxDist: Integer): TRSObjectArray;
By: mormonman
Description: Returns an array of all objects within the MaxDist with the ID.
Sorted from closest to the your player.
MaxDist: This is the maximum distance from your player you wish to
search. The smaller the number, the faster the search is
completed. The maximum is 52.
*******************************************************************************}
function GetObjectsByID(ID: Integer; objType, MaxDist: Integer): TRSObjectArray;
begin
Result := GetObjectsByIDEx([ID], objType, MaxDist);
end;

:(

bugger0001

2011-01-12 05:12:53

What I meant was that you were missing the s I bolded from your initial code. You used a function called GetObjectByID which results a TRSObject, but your variable Rocks is declared as TRSObjectArray. Therefore you need to use GetObjectsByID. Hope that was a bit easier to understand :p

DeSnob

2011-01-12 07:12:05

From: bugger0001
What I meant was that you were missing the s I bolded from your initial code. You used a function called GetObjectByID which results a TRSObject, but your variable Rocks is declared as TRSObjectArray. Therefore you need to use GetObjectsByID. Hope that was a bit easier to understand :p


I understood completely. I know what I'm doing. I just don't understand why it isn't working…Before I took the s I had it already. I know arrays and I can create well working (private) scripts. This used to work but for some reason it just stopped working. That's what I don't understand.

bugger0001

2011-01-12 07:20:50

Well, I'm not aware of all the recent updates to Reflection, but my guess would be that the above mentioned functions were rewritten at some point, because the current output type of GetObjectByID does not fit in to your architecture.

EDIT: I assume this is the case: http://villavu.com/forum/showthread.php?t=60858

**BANNED The Man

2011-01-12 14:32:43

Could you post the entire script?
Or the 2 functions involved please?