SRL Archive - OSR Help

Clicking on a spell using DTM


gdsht

2012-05-11 12:33:30

Just wondering what the correct way to click on a DTM is. Currently building my first script and have encountered some trouble. Read all of the beginner guides and examines a lot of scripts that perform similar functions and I know I am missing something obvious.

Is this the right way to be going about things?

procedure ClickEnchant;
begin
if(finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 5, 5,);
ClickMouse2(Mouse_Left);
end;
end;


I have Spellpos defined above

SpellPos :=  DTMFromString('m1gAAAHic42JgYDBlgWB7ILYEYm0g1gNiFyB2AGJ1ILYC4meMDAwfgfgpEN8B4vtA/AmI3wLxbSB+B8QfgDjGTRNoKhMRmDjASCRGAACU/QxT');

Any help or hints to correct what I'm sure is terrible writing would be much appreciated!

CephaXz

2012-05-11 12:34:59

Just use mouse, mousebox or mousecircle. Can check the uptext also if you want. Make things easier than DTM.

gdsht

2012-05-11 12:38:05

I originally attempted that, but couldn't get that working either *helpless*

That method would involve using tbox yes?

Abu

2012-05-11 12:38:30

Yes that is the correct way.

As a failsafe, you could check for uptext before moving your mouse:
procedure ClickEnchant;
begin
if(finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 0, 0);
if IsUptext('spellName') then
Mouse(x, y, 5, 5, True);
end;
end;

gdsht

2012-05-11 12:40:21

Thank you very much! I'll doubtlessly be back when the next problem arises.

<3

Abu

2012-05-11 12:41:01

No problem - just read the function again as I made a mistake earlier which I just fixed :duh:

Feeshie

2012-05-11 12:50:38

Thanks for asking this man. I was going to ask this later today as well, I have almost the exact same code as the OP, but it would not click the spell.

Harry

2012-05-11 12:52:38

MMouse(x, y, 0, 0);
if IsUptext('spellName') then
Mouse(x, y, 5, 5, True);
end;
Nope, don't do that. Move first with your randomness, then if it has uptext getMousePos and click 0,0 randomness. Other than that yeah seems accurate. (correcting abu's, not yours)

putonajonny

2012-05-11 12:57:55

From: abu_jwka
Yes that is the correct way.

As a failsafe, you could check for uptext before moving your mouse:
procedure ClickEnchant;
begin
if(finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 0, 0);
if IsUptext('spellName') then
Mouse(x, y, 5, 5, True);
end;
end;


procedure ClickEnchant;
begin
if(finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 0, 0);
if WaitUpText('spellName', 500+Random(500)) then //Wait up text is a lot better incase RS / your computer lags...
ClickMouse2(mouse_Left); //You don't want more randomness after the mouse has stopped moving...
end;
end;

gdsht

2012-05-11 13:02:40

Will add it, thanks for the input!

gdsht

2012-05-11 13:52:42

Back again, I'm afraid the procedure is not working, it swaps to the magic tab but does not click the spell or move the mouse. Neither does it print DTM not found. Any pointers?

Sorry if this is obvious to everyone else what the error is >.>

 procedure ClickEnchant;
begin
if not (GetCurrentTab = tab_Magic) then
if FindNormalRandoms then
Exit
else
GameTab(tab_Magic);
if(finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 0, 0);
if WaitUpText('Enchant Crossbow Bolt', 500 + Random(500)) then //Wait up text is a lot better incase RS / your computer lags...
ClickMouse2(mouse_Left) //You don't want more randomness after the mouse has stopped moving...
else
writeln ('Could not find Enchant DTM');
end;

end;

Runaway

2012-05-11 13:59:56

I fixed your standards, you were missing a few semi-colons and I think the if then statements were funky. Could very well have been the problem:


procedure ClickEnchant;
begin
if not (GetCurrentTab = tab_Magic) then
begin
if FindNormalRandoms then Exit;
else GameTab(tab_Magic);
end;
if(FindDTM(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(x, y, 3, 3);
if WaitUpText('Enchant Crossbow Bolt', 500 + Random(500)) then
ClickMouse2(mouse_Left);
else Writeln ('Could not find Enchant DTM');
end;
end;

Abu

2012-05-11 14:08:17

See if this works:
procedure ClickEnchant;
var
spellpos, x, y: Integer;
begin
if FindNormalRandoms then Exit;

if not (GetCurrentTab = tab_Magic) then
GameTab(tab_Magic);

if (finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
MMouse(x, y, 3, 3);
if WaitUpTextMulti(['ncha', 'rossb'], 1000 + Random(500)) then
ClickMouse2(mouse_Left)
else
Writeln ('Could not find Enchant DTM');
end;
end;

EDIT: :ninja: 'd by Runaway

gdsht

2012-05-11 14:18:31

Tried both variants, and now the script swaps from spellbook to inventory. Any clues?


Perhaps it would be easier if I posted the code in its entirety?

Total

2012-05-11 14:19:02


procedure ClickEnchant;
var
spellpos, x, y: Integer;
begin
if FindNormalRandoms then Exit;
if not (GetCurrentTab = tab_Magic) then
GameTab(tab_Magic);
if (finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
MMouse(x, y, 3, 3);
if WaitUpTextMulti(['ncha', 'rossb'], 1000 + Random(500)) then
ClickMouse2(mouse_Left)
end else
Writeln('Couldnt find DTM');
end;

Try that instead…it should now say it couldn't find DTM if it doesn't find it. You had the else in the wrong place.

gdsht

2012-05-11 14:23:20

From: TotalKillz

procedure ClickEnchant;
var
spellpos, x, y: Integer;
begin
if FindNormalRandoms then Exit;
if not (GetCurrentTab = tab_Magic) then
GameTab(tab_Magic);
if (finddtm(Spellpos, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
MMouse(x, y, 3, 3);
if WaitUpTextMulti(['ncha', 'rossb'], 1000 + Random(500)) then
ClickMouse2(mouse_Left)
end else
Writeln('Couldnt find DTM');
end;

Try that instead…it should now say it couldn't find DTM if it doesn't find it. You had the else in the wrong place.


Ahhh, there we go. It's a problem on my side with the DTM :fiery:

Cheers for the help everyone, I'll get back to it!