SRL Archive - SRL Snippets

Player Owned Ports Navigation


xtrapsp

2013-03-28 07:47:55

Been working on a script and have this snippet. Feel free to improve etc. But it works for me




(*
Dockbutton
~~~~~~~~~~

.. code-block:: pascal

function Dockbutton(Button: Integer): Boolean;

If the button is available to click, the function will click the button and return
true or false.Passing 1-6 will use the ability in the coordinating area.

.. note::

by xtrapsp
Last modified: March. 28th, 2013 by Xtrapsp

Example:

.. code-block:: pascal


if Dockbutton(3) then
WriteLn('Clicked the Dockbutton{3} which is shipyard');
*)
function Dockbutton(Button: Integer): Boolean;
var
X, Y: Integer;
begin
Result := False;
case (Button) of
1:
begin
Writeln('Clicking Voyages Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
2:
begin
Writeln('Clicking Crew Roster Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
3:
begin
Writeln('Clicking Shipyard Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
4:
begin
Writeln('Clicking Upgrades Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
5:
begin
Writeln('Clicking Port Management Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
6:
begin
Writeln('Clicking Upgrades Button');
HumanMMouse(207,73-50,4,4);
Result := True;
exit;
end;
end;
end;

Runehack123

2013-03-28 07:49:09

what does it do? :)
you title says player owned ports but I don't know what it does exact please tell us ali baba!

xtrapsp

2013-03-28 07:50:13

From: Runehack123
what does it do? :)
you title says player owned ports but I don't know what it does exact please tell us ali baba!


 {  function Dockbutton(Button: Integer): Boolean;

If the button is available to click, the function will click the button and return
true or false.Passing 1-6 will use the ability in the coordinating area.}

Runehack123

2013-03-28 07:51:34

I still don't understand hahahaha :o !!!!

please explain more I don't understand your explanation

e,g, youy say function will return true or false but when does it return true and when does it return false and what is this 1tosix abt!?

xtrapsp

2013-03-28 07:53:00

From: Runehack123
I still don't understand hahahaha :o !!!!

please explain more I don't understand your explanation


it clicks the buttons in the menu. I added a picture above

Runehack123

2013-03-28 07:54:06

From: xtrapsp
it clicks the buttons in the menu. I added a picture above

oh thank so much
that really helpd me understand :)

why does it return true or fals and when does it dio> that??

xtrapsp

2013-03-28 07:55:03

From: Runehack123
oh thank so much
that really helpd me understand :)

why does it return true or fals and when does it dio> that??


Well, if you want it to return true or false you can check if it has or has not clicked it. I don't know if it will fail or not so I'm pretty much writing it off the bat while learning the minigame

Depends on how people want to expand on it really

Runehack123

2013-03-28 08:02:39

right now it's not clicking any button thoguh because all is just moving mouse you should make it so it clicks mouse because you said it do in your descript I can change that for you and make it better? :)

Flight

2013-03-28 08:47:26

Yeah I believe you're missing a couple things here bud. From the looks of it this function will always move the mouse to coordinate (207,23) with 4 X/Y randomness. Also, it never actually clicks, just mouse movement.

Runehack123

2013-03-28 08:52:47

From: Flight
Yeah I believe you're missing a couple things here bud. From the looks of it this function will always move the mouse to coordinate (207,23) with 4 X/Y randomness. Also, it never actually clicks, just mouse movement.


yes this like I already say only random mouse movement
I can complete this if you want ClickMouse2(True);
sec…

(*
Dockbutton
~~~~~~~~~~

.. code-block:: pascal

function Dockbutton(Button: Integer): Boolean;

If the button is available to click, the function will click the button and return
true or false.Passing 1-6 will use the ability in the coordinating area.

.. note::

by xtrapsp
Last modified: March. 28th, 2013 by Xtrapsp

Example:

.. code-block:: pascal


if Dockbutton(3) then
WriteLn('Clicked the Dockbutton{3} which is shipyard');
*)
function Dockbutton(Button: Integer): Boolean;
var
X, Y: Integer;
begin
Result := False;
case (Button) of
1:
begin
Writeln('Clicking Voyages Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
2:
begin
Writeln('Clicking Crew Roster Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
3:
begin
Writeln('Clicking Shipyard Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
4:
begin
Writeln('Clicking Upgrades Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
5:
begin
Writeln('Clicking Port Management Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
6:
begin
Writeln('Clicking Upgrades Button');
HumanMMouse(207,73-50,4,4);
ClickMouse2(True);
Result := True;
exit;
end;
end;
end;

THERE I FIX YOUR SNIPPET LIKE A DREAM BOSS ;) IN YOUR BEST DREAM

xtrapsp

2013-03-28 09:00:06

From: Flight
Yeah I believe you're missing a couple things here bud. From the looks of it this function will always move the mouse to coordinate (207,23) with 4 X/Y randomness. Also, it never actually clicks, just mouse movement.


Think I should put a mouse box around the icons?

Runehack123

2013-03-28 09:02:19

From: xtrapsp
Think I should put a mouse box around the icons?


No I don't think it's needed 4,4 pixel change isnt much and still leaves you within the button so I dont think it's needed. But of course you can if you like it ;)
also homo sapiens player always clicks in middle of object so if you mousebox Iwouldnt do it around whole of the button otherwise it might look a little strange

Flight

2013-03-28 09:03:35

How about this instead? (Keep in mind you'll want to adjust the X/Y coordinates)


function Dockbutton(Button: Integer): Boolean;
var
bString: String;
xCoord,yCoord: Integer;
begin
Result := InRange(Button, 1, 6);
case (Button) of
1:
begin
bString := 'Voyages';
xCoord := 207;
yCoord := 73;
end;
2:
begin
bString := 'Crew Roster';
xCoord := 207;
yCoord := 73;
end;
3:
begin
bString := 'Shipyard';
xCoord := 207;
yCoord := 73;
end;
4:
begin
bString := 'Upgrades';
xCoord := 207;
yCoord := 73;
end;
5:
begin
bString := 'Port Management';
xCoord := 207;
yCoord := 73;
end;
6:
begin
bString := 'Map';
xCoord := 207;
yCoord := 73;
end;
end;

if Result then
begin
Writeln('Clicking '+bString+' Button');
HumanMMouse(xCoord, yCoord-50, 4, 4);
ClickMouse2(mouse_left);
end;
end;

xtrapsp

2013-03-28 09:07:44

From: Flight
How about this instead? (Keep in mind you'll want to adjust the X/Y coordinates)


function Dockbutton(Button: Integer): Boolean;
var
bString: String;
xCoord,yCoord: Integer;
begin
Result := InRange(Button, 1, 6);
case (Button) of
1:
begin
bString := 'Voyages';
xCoord := 207;
yCoord := 73;
end;
2:
begin
bString := 'Crew Roster';
xCoord := 207;
yCoord := 73;
end;
3:
begin
bString := 'Shipyard';
xCoord := 207;
yCoord := 73;
end;
4:
begin
bString := 'Upgrades';
xCoord := 207;
yCoord := 73;
end;
5:
begin
bString := 'Port Management';
xCoord := 207;
yCoord := 73;
end;
6:
begin
bString := 'Map';
xCoord := 207;
yCoord := 73;
end;
end;

if Result then
begin
Writeln('Clicking '+bString+' Button');
HumanMMouse(xCoord, yCoord-50, 4, 4);
ClickMouse2(mouse_left);
end;
end;


Ahh, didn't think of formatting it like that, is there any difference in benefit for doing this way just out of curiosity. (Only because after reading it I can't see a reason as to why but it is easier to read and understand)

Thanks :)

Flight

2013-03-28 09:10:40

From: xtrapsp
Ahh, didn't think of formatting it like that, is there any difference in benefit for doing this way just out of curiosity. (Only because after reading it I can't see a reason as to why but it is easier to read and understand)

Thanks :)


Ah nah mate, it's all just preference. I'm not sure if the block I posted above is less lines or not, it's just how I would go about doing that. In the end the same goal is accomplished, no?

xtrapsp

2013-03-28 09:21:02

From: Flight
Ah nah mate, it's all just preference. I'm not sure if the block I posted above is less lines or not, it's just how I would go about doing that. In the end the same goal is accomplished, no?


Yea ;P I think I like yours better haha. +REP

rj

2013-03-28 18:35:21

Do you still need that SPS map?

xtrapsp

2013-03-28 20:13:19

From: RJJ95
Do you still need that SPS map?


if it's going, I'l use it for randoms.

Thanks

rj

2013-03-28 20:15:17

From: xtrapsp
if it's going, I'l use it for randoms.

Thanks


wait what if what is going?

xtrapsp

2013-03-29 13:15:07

From: RJJ95
wait what if what is going?


The chance of someone having time to make me the map ahaha

Olly

2013-03-29 15:08:20

another way to do things..

const
DOCK_BUTTON_VOYAGES = 0;
//etc...

function clickDockButton(button: integer): boolean;
var
pnt: array [0..6] of TPoint;
begin
pnt := [point(207, 73), point(207, 73), point(207, 73), point(207, 73), point(207, 73), point(207, 73)];
result := inRange(button, 0, 6);

if (result) then
mouse(pnts[button].x, pnt[button].y, 3, 3, MOUSE_LEFT)
else
writeln('Invaild button!');

end;

begin
clickDockButton(DOCK_BUTTON_VOYAGES);
end.

Le Jingle

2013-03-29 16:18:50

:) Throw in some constants too, that helps ;)


procedure DockButton(Button: Integer);
begin
if (inRange(Button, 0, 5)) then
Mouse(207 + (Button mod 3) * 53, 23 + (Button div 3) * 36, 15, 15, Mouse_Left);
end;