SRL Archive - OSR Help

Need help with my script


0r4nge ownz

2013-05-30 06:12:37

Hello firstly, I'm a real big noob. Im no coder, I know very little.

I used PowerFlop by Aaron126 and ripped it to make this.

All I want it to do is use Mithril bolts (unf) with Feathers. As simple as that :)

When I try to run I get this error:
[Error] C:\Simba\Scripts\Myattempt.simba(381:4): Identifier expected at line 380
Compiling failed.

BY THE WAY - Line 380 is last line in this script. The 'end.'


SCRIPT:

Program MithBoltFletcher;
{$define SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}

var
WarningInfo: string;
BoltsX, BoltsY, FeathersX, FeathersY, RepeatCount:Integer;
DebugOverride:Boolean;

const
BoltsSlot = 1; // Inventory slot that your Bolts are in (1 through 28)
FeathersSlot = 2; // Inventory slot that your axe is in, 0 if wielding your axe (1 through 28)

Procedure DeclarePlayer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; //Username goes here
Players[0].Pass := ''; //Password goes here
Players[0].Nick := ''; //Character name (excluding first letter)
Players[0].Active := True;
end;
(******************************************************************************)
(* END OF COFIGURATION *)
(******************************************************************************)


Function ContainsText(CheckText: String; Text: TStringArray): Boolean;
Var
TheText: String;
i, n: Integer;
Begin
TheText := CheckText;
n := High(Text);
For i := 0 to n do
If (Pos(Text, TheText) > 0) then
Begin
Result := True;
Exit;
End;
End;

Procedure randomMouseClick(mx,my: Integer);
begin
case random(200) of
1..160: Mouse(RandomRange(mx - 7, mx + 7), RandomRange(my - 7, my + 7), 2, 2, true);
161..190: Mouse(RandomRange(mx - 9, mx + 9), RandomRange(my - 9, my + 9), 2, 2, true);
191..200: Mouse(RandomRange(mx - 12, mx + 12), RandomRange(my - 12, my + 12), 2, 2, true);
end;
end;

Procedure GetFeathersCoords;
begin
FeathersX := 0;
FeathersY := 0;

case (FeathersSlot) of
1:
begin
FeathersX := 575;
FeathersY := 230;
end;
2:
begin
FeathersX := 620;
FeathersY := 230;
end;
3:
begin
FeathersX := 665;
FeathersY := 230;
end;
4:
begin
FeathersX := 710;
FeathersY := 230;
end;
5:
begin
FeathersX := 575;
FeathersY := 265;
end;
6:
begin
FeathersX := 620;
FeathersY := 265;
end;
7:
begin
FeathersX := 665;
FeathersY := 265;
end;
8:
begin
FeathersX := 710;
FeathersY := 265;
end;
9:
begin
FeathersX := 575;
FeathersY := 300;
end;
10:
begin
FeathersX := 620;
FeathersY := 300;
end;
11:
begin
FeathersX := 665;
FeathersY := 300;
end;
12:
begin
FeathersX := 710;
FeathersY := 300;
end;
13:
begin
FeathersX := 575;
FeathersY := 335;
end;
14:
begin
FeathersX := 620;
FeathersY := 335;
end;
15:
begin
FeathersX := 665;
FeathersY := 335;
end;
16:
begin
FeathersX := 710;
FeathersY := 335;
end;
17:
begin
FeathersX := 575;
FeathersY := 370;
end;
18:
begin
FeathersX := 620;
FeathersY := 370;
end;
19:
begin
FeathersX := 665;
FeathersY := 370;
end;
20:
begin
FeathersX := 710;
FeathersY := 370;
end;
21:
begin
FeathersX := 575;
FeathersY := 405;
end;
22:
begin
FeathersX := 620;
FeathersY := 405;
end;
23:
begin
FeathersX := 665;
FeathersY := 405;
end;
24:
begin
FeathersX := 710;
FeathersY := 405;
end;
25:
begin
FeathersX := 575;
FeathersY := 440;
end;
26:
begin
FeathersX := 620;
FeathersY := 440;
end;
27:
begin
FeathersX := 665;
FeathersY := 440;
end;
28:
begin
FeathersX := 710;
FeathersY := 440;
end;
end;

if (BoltsSlot > 28) then
begin
writeln(' FATAL! Invalid Feathers slot specified, must be between 0 and 28!');
TerminateScript;
end;
end;

Procedure GetBoltsCoords;
begin
BoltsX := 0;
BoltsY := 0;

case (BoltsSlot) of
1:
begin
BoltsX := 575;
BoltsY := 230;
end;
2:
begin
BoltsX := 620;
BoltsY := 230;
end;
3:
begin
BoltsX := 665;
BoltsY := 230;
end;
4:
begin
BoltsX := 710;
BoltsY := 230;
end;
5:
begin
BoltsX := 575;
BoltsY := 265;
end;
6:
begin
BoltsX := 620;
BoltsY := 265;
end;
7:
begin
BoltsX := 665;
BoltsY := 265;
end;
8:
begin
BoltsX := 710;
BoltsY := 265;
end;
9:
begin
BoltsX := 575;
BoltsY := 300;
end;
10:
begin
BoltsX := 620;
BoltsY := 300;
end;
11:
begin
BoltsX := 665;
BoltsY := 300;
end;
12:
begin
BoltsX := 710;
BoltsY := 300;
end;
13:
begin
BoltsX := 575;
BoltsY := 335;
end;
14:
begin
BoltsX := 620;
BoltsY := 335;
end;
15:
begin
BoltsX := 665;
BoltsY := 335;
end;
16:
begin
BoltsX := 710;
BoltsY := 335;
end;
17:
begin
BoltsX := 575;
BoltsY := 370;
end;
18:
begin
BoltsX := 620;
BoltsY := 370;
end;
19:
begin
BoltsX := 665;
BoltsY := 370;
end;
20:
begin
BoltsX := 710;
BoltsY := 370;
end;
21:
begin
BoltsX := 575;
BoltsY := 405;
end;
22:
begin
BoltsX := 620;
BoltsY := 405;
end;
23:
begin
BoltsX := 665;
BoltsY := 405;
end;
24:
begin
BoltsX := 710;
BoltsY := 405;
end;
25:
begin
BoltsX := 575;
BoltsY := 440;
end;
26:
begin
BoltsX := 620;
BoltsY := 440;
end;
27:
begin
BoltsX := 665;
BoltsY := 440;
end;
28:
begin
BoltsX := 710;
BoltsY := 440;
end;
end;

if (BoltsSlot > 28) then
begin
writeln(' FATAL! Invalid Bolt slot specified, must be between 0 and 28!');
TerminateScript;
end;
end;

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);
repeat
mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);

Begin
DeclarePlayer;
SetupSRL;
GetBoltsCoords;
GetFeathersCoords;
SetBrightness(4);
ClearDebug;
end.



Its properly all wrong anyway :(

Chris!

2013-05-30 06:17:19

At line 372, you need to add an until as you need to cut off your repeat loop and on line 373 you need an end;!

Always remember, for every if you need a then, for every repeat you need an until and for every begin you need an end! Improving your standards (script formatting) will help you debug your script if you're getting errors!

0r4nge ownz

2013-05-30 06:21:43

From: Chris!
At line 372, you need to add an until as you need to cut off your repeat loop and on line 373 you need an end;!

Always remember, for every if you need a then, for every repeat you need an until and for every begin you need an end! Improving your standards (script formatting) will help you debug your script if you're getting errors!


Lol you make it sound so easy, thank you very much for your help ^^

0r4nge ownz

2013-05-30 06:23:44

Still getting errors :(

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);
repeat
mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
until
end; (LINE 373)
Begin
DeclarePlayer;
SetupSRL;
GetBoltsCoords;
GetFeathersCoords;
SetBrightness(4);
ClearDebug;
end.

[Error] C:\Simba\Scripts\Myattempt.simba(374:1): Syntax error at line 373
Compiling failed.


Also sorry for asking for so much but, is this procedure correct?
Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);
repeat
mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
until
end;

Will that make the BoltsX&BoltsY use on the FeathersX&FeathersY?

Haxz

2013-05-30 06:31:10

There's nothing behind your until. Script won't know when to end the repeat statement.

EngageTheRage

2013-05-30 06:33:38

ok so here's your problem:

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);

repeat
mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
until // until what here?????
end;

Begin
DeclarePlayer;
SetupSRL;
GetBoltsCoords;
GetFeathersCoords;
SetBrightness(4);
ClearDebug;
end.

you see your until where i have commented next to? you have to use unti like this:

repeat
// do something
until(false)

in the brackets can be any boolean statement, the repeat continues whilst the boolean statement is false, once it becomes true the repeat finished and the script moves on.

and as for it being correct, what is the repeat for? i am unfamiliar with fletching but maybe it should besomething like this:

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);

mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
end;

so you are justing clicking on bolts, then clicking on feathers. to repeat this procedure you can call it within a loop in a different procedure/function. for example:


procedure mainLoop;
begin
// blah blah blah

while((getBolts) and (getFeathers)) do
begin
Fletch;
end;

// blah blah blah
end;

i hope thats what you were after and it helped a little :D

0r4nge ownz

2013-05-30 06:38:59

Yh I see the problem, I just took out repeat & until and the problem was solved. It now logs me in :)

0r4nge ownz

2013-05-30 06:44:32

From: EngageTheRage
ok so here's your problem:

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);

repeat
mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
until // until what here?????
end;

Begin
DeclarePlayer;
SetupSRL;
GetBoltsCoords;
GetFeathersCoords;
SetBrightness(4);
ClearDebug;
end.

you see your until where i have commented next to? you have to use unti like this:

repeat
// do something
until(false)

in the brackets can be any boolean statement, the repeat continues whilst the boolean statement is false, once it becomes true the repeat finished and the script moves on.

and as for it being correct, what is the repeat for? i am unfamiliar with fletching but maybe it should besomething like this:

Procedure Fletch;
begin
GameTab(Tab_Inv);
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);

mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
end;

so you are justing clicking on bolts, then clicking on feathers. to repeat this procedure you can call it within a loop in a different procedure/function. for example:


procedure mainLoop;
begin
// blah blah blah

while((getBolts) and (getFeathers)) do
begin
Fletch;
end;

// blah blah blah
end;

i hope thats what you were after and it helped a little :D


Ok that makes loads more sence…
But the main loop, I'l put that in. But how does the script know when to start the mainLoop? Do I put it in with startup procedure?

EngageTheRage

2013-05-30 06:57:09

the only part the script automatically executes is what is contained on the "begin-end;" that you have at the end. within here you can create a repeat-until(false) so that a set of operations/procedures are continuously carried out.

an example:

program Exmaple;
{$DEFINE SMART8}
{$i SRL-OSR/Srl.simba}

var
boltsX, boltsY, feathersX, feathersY: Integer;

// here will have all your setupSRL, declare players etc.

function FindBolts: Boolean;
var
xc, yc: integer;
begin
Result := False;
// here you do you stuff to find the bolts ie.
if(findobject/DTM/Color/ etc) then
begin
boltsX := xc;
boltsY := yc;
Result := True;
end;
end;

function FindFeathers: Boolean;
var
xc, yc: integer;
begin
Result := False;
// here you do you stuff to find the Feathers ie.
if(findobject/DTM/Color/ etc) then
begin
feathersX := xc;
feathersY := yc;
Result := True;
end;
end;

Procedure Fletch;
begin
mmouse(BoltsX, BoltsY, 5, 5);
Clickmouse2(mouse_left);

mmouse(FeathersX, FeathersY, 5, 5);
Clickmouse2(mouse_left);
end;

begin // this is the part executed when script starts

// here you will call setupSrl, declare players etc ...

GameTab(Tab_Inv);
while((FindBolts) & (FindFeathers)) do // so this while loop will go on
begin // as long as bolts & feathers are
Fletch; // found.
wait(RandomRange(50, 250));
end;
end;

0r4nge ownz

2013-05-30 07:00:12

I'm clearly not knowledgeable enough to do this lol :/

Would anyone do the finishing touches to this?
It would be a very good script, because this is like 400k a hour fleching exp apparently with no loss in gp.
http://up.ht/149HuEi

You can release it as well, as long as I get to use it :)

I did go further than I expected with this lol, I thought I was going to stop on the first error :) I'm pleased with myself :D

Rich

2013-05-31 09:57:41

[QUOTE=0r4nge ownz;1244195You can release it as well, as long as I get to use it :)You'll want to ask Aarson126 before releasing anything, since it'd based off his script.