SRL Archive - MSI Help

Can Someone explain why this gives me a type mismatch?


the flea

2012-03-15 09:35:50

Like the title said why does this give me a type mismatch. As you can probably tell I'm new to MSI and still getting to grips with it fully so if I have done anything wrong / unconventional please let me know.

I'm trying to use
function MSI_GotFlax: Boolean;
begin
Result := MSI_AutoInvFull(@MSI_PickFlax);
end;

this is pointed to at the autoobjects procedure of the script. however I am getting the error
(255:45): Type mismatch at line 254
Line 254 is the line with Result := MSI_AUTOINV… on it.

it is pointing to MSI_PickFlax which is this:

function MSI_PickFlax: boolean;
var
flax: TMSObject;
TmpTPA: TPointArray;
tmpPoint: Tpoint;
i,x,y: integer;
begin
if (not loggedIn) then
exit;

flax := MSI_GetObject(OBJ_FLAX);

MSI_FindObjectTPA(flax, TmpTPA);
for i:=0 to High(TmpTPA) do
begin
tmpPoint := tmpTPA[i];
MMouse(tmppoint.x,tmppoint.y,1,1);
if (isuptextmulticustom(['ick','lax'])) then
begin
GetMousePos(x,y);
Mouse(x, y, 0, 0, true);
FFlag(0);
wait(300+random(150));
Result := true;
exit;
end;
end;
end;

any help big or little would be greatly appreciated thanks :)

Abu

2012-03-15 14:34:28

Remove the @ sign and hit compile again, I'm pretty certain its not required…


But then again, I don't know the parameters needed for the function..

masterBB

2012-03-15 14:38:22

function MSI_PickFlax(objs: TIntegerArray): boolean;  //the TIntegerArray is required as input.
var
flax: TMSObject;
TmpTPA: TPointArray;
tmpPoint: Tpoint;
i,x,y: integer;
begin
if (not loggedIn) then
exit;

flax := MSI_GetObject(OBJ_FLAX);

MSI_FindObjectTPA(flax, TmpTPA);
for i:=0 to High(TmpTPA) do
begin
tmpPoint := tmpTPA[i];
MMouse(tmppoint.x,tmppoint.y,1,1);
if (isuptextmulticustom(['ick','lax'])) then
begin
GetMousePos(x,y);
Mouse(x, y, 0, 0, true);
FFlag(0);
wait(300+random(150));
Result := true;
exit;
end;
end;
end;

edit:
proof: function MSI_AutoInvFull(auto: function(objs: TIntegerArray): boolean): boolean;

Sex

2012-03-15 14:41:24

From: abu_jwka
Remove the @ sign and hit compile again, I'm pretty certain its not required…


But then again, I don't know the parameters needed for the function..


The @ sign is required as MSI_AutoInvFull needs a pointer to a function.

@OP: The function you provide needs a TIntegerArray parameter, not sure what it is/does though..

Edit: :ninja:'d.

masterBB

2012-03-15 14:45:30

It isn't used.

edit:

nvm, I am an idiot.
 with MSI_Players[CurrentPlayer] do
begin
RunEnergy(20);
GameTab(TAB_INV);
tObjects := MSI_GetPlayerObjects();

if (not MSI_Scripts[Scripts[CurrentScript].Name].ClickClosest) then
newObjects := MSI_RearrangeArray(tObjects, Scripts[CurrentScript].Priority)
else
newObjects := tObjects;

if (TimeFromMark(waitTime) >= tTime) then
waitTime := 0;

if (auto(newObjects)) then //here is it used

edit:
lol, this thread was here for more then five hours. Still we managed to post on the same time :P

the flea

2012-03-15 14:59:48

thanks for your help guys :) got it working now just doing some testing

Coh3n

2012-03-15 16:02:29

Oo a flax picker! :) I hope you're planning on sending a pull request.

the flea

2012-03-16 07:04:58

From: Coh3n
Oo a flax picker! :) I hope you're planning on sending a pull request.


yes I will be once I have tested it properly and made it a bit more smoother. It's working at the moment but its not perfect.

I don't know how to add stuff into the form though? I used your tutorial but the form section was missing from it :(

Kyle Undefined

2012-03-16 11:02:26

When adding the scripts, the form should automatically load the script into the form for you ;)

the flea

2012-03-16 11:03:23

From: Kyle Undefined
When adding the scripts, the form should automatically load the script into the form for you ;)


oh really I didn't know this so just automatically decided to run it without the form.:duh:

Coh3n

2012-03-16 20:12:24

From: Kyle Undefined
When adding the scripts, the form should automatically load the script into the form for you ;)


From: the flea
oh really I didn't know this so just automatically decided to run it without the form.:duh:
Some things will need to be added.

And I left it out of my guide because I'm writing a new form that will be 1000x easier to update. Once that's done, I'll be adding a section in the guide for the form.

I don't expect you to edit the form as it's quite messy and difficult to understand. If you get it working smoothly (if you need help with that, PM myself of Kyle) let me know and I can add in the form code as it'll only take me a few minutes.