PDA

View Full Version : How would I do this?



One Kid
12-31-2015, 06:49 PM
Going from something messy like this.

procedure GEClickBuy(Slot:integer);
var
a, b:TReflectWidget;
begin
A.GetWidget(465, Slot+6);
B.GetChild(A, 0);
Reflect.Mouse.Move(Point(
RandomRange(b.GetBounds.X1, b.GetBounds.X2),
RandomRange(b.GetBounds.y1, b.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
Wait(RandomRange(400,750));
A.free;
B.free;
end;

To something where I would type:

function GE.Slot().ClickBuy;


Any idea on how I would do something like this? Would I use records with pointers in them and assign the pointers to the necessary functions/procedures? How would I pass parameters to the pointers, like in the case above, a slot number?

Any help would be great! :D

Kyle
12-31-2015, 07:28 PM
AFAIK you can't chain a procedure/function in lape, so you couldn't do that. The closest I can see is doing something like this:

program Meh;
{$DEFINE SMART}
{$i Reflection/Reflection.simba}

type TSlotInterface = record
Slot: Integer;
end;

type TGrandExchange = record
Slot: TSlotInterface;
end;

procedure TSlotInterface.Init(S: Integer);
begin
Self.Slot := S;
end;

procedure TSlotInterface.ClickBuy;
var
a, b:TReflectWidget;
begin
A.GetWidget(465, Self.Slot + 6);
B.GetChild(A, 0);
Reflect.Mouse.Move(Point(
RandomRange(B.GetBounds.X1, B.GetBounds.X2),
RandomRange(B.GetBounds.y1, B.GetBounds.y2)
), 0, 0);
Reflect.Mouse.Click(mouse_left);
Wait(RandomRange(400,750));
A.free;
B.free;
end;

var
GE: TGrandExchange;

begin
Reflect.Setup;
Ge.Slot.Init(2);
Ge.Slot.ClickBuy;
end.

Though, that's much worse than the original way, so I'd just keep that.. Maybe someone else can chime in but idk what else can be done in lape, other than defining each slot separately under the TGrandExchange Record

yourule97
12-31-2015, 07:35 PM
I think you should take a look at this record tutorial, I think it will help a lot: https://villavu.com/forum/showthread.php?t=113227

I'm not entirely clear on what you're asking though for your script. You could I guess create a record called GESlot have have the function GESlot.clickBuy(slot : integer). If you wanted an over-arching record, called something like GE and have under it a bunch of different records, I'm not actually sure if you can do that.

Also, I'm not entirely certain on why you need want to implement this especially if you can just create it as a local method and reference it whenever you need to. But if you really want some more practice with records, so that you can implement what you're thinking, take a look at the SRL-6 source code implementation of grand exchange code.

I also toyed a little with records in my looter script, which you can look at yourself in my signature. I hope this helps!

One Kid
01-01-2016, 05:32 AM
I think you should take a look at this record tutorial, I think it will help a lot: https://villavu.com/forum/showthread.php?t=113227

I'm not entirely clear on what you're asking though for your script. You could I guess create a record called GESlot have have the function GESlot.clickBuy(slot : integer). If you wanted an over-arching record, called something like GE and have under it a bunch of different records, I'm not actually sure if you can do that.

Also, I'm not entirely certain on why you need want to implement this especially if you can just create it as a local method and reference it whenever you need to. But if you really want some more practice with records, so that you can implement what you're thinking, take a look at the SRL-6 source code implementation of grand exchange code.

I also toyed a little with records in my looter script, which you can look at yourself in my signature. I hope this helps!

Thanks for the information. I just want to create an include I suppose that people could use which is familiar to that of the Reflection include in that its methods and procedures are accessed in the same way that I would like to implement.


Edit:

Figured it out, will post an include when I have finished with the development of it.