SRL Archive - OSR Help

Will this procedure work?


FuruChan

2011-02-08 00:39:41


procedure SetupMineRocks;
var
X, Y, i: integer;
RockColor: array[0..3] of integer;
begin
if (RockType = 'iron') then
writeln('Mining iron ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
else
if (RockType = 'tin') then
writeln('Mining tin ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
else
if (RockType = 'copper') then
writeln('Mining copper ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
begin
if(not(LoggedIn)) then
Exit;
else
For i:= 0 to 5 do
if(FindObjCustom(x,y,['ine','in','ne','ocks','ock'],[RockColor[i]],6) then
begin
if IsUpText('ocks') then
begin
MineRocks;
end;
end;
end;
end;

It doesn't compile right now because it says identifier expected. Can anyone tell me why? Also, is the RSS Channel accessible so I can ask quick question like this on there? :duh:

i luffs yeww

2011-02-08 00:49:50

For quick questions/answers, go to #srl.

FuruChan

2011-02-08 01:06:10

Can you touch up on that a bit, I can't seem to find the thread that tells me how to join the IRC.

Sex

2011-02-08 01:09:09

Um, get an IRC client like mIRC xChat irssi or something. Then join the channel. Its #srl on irc.rizon.net.

Bonfield

2011-02-08 01:26:28

i made it compile
{$i SRL/SRL.scar}

procedure MineRocks;
begin
end;

procedure SetupMineRocks;
var
X, Y, i, ii: integer; // ii added
RockColor: array[0..3] of integer;
RockType: String;

begin
if (RockType = 'iron') then
begin // missing a begin here
writeln('Mining iron ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
end else // need to use end else here
if (RockType = 'tin') then
begin
writeln('Mining tin ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
end else // same as before
if (RockType = 'copper') then
begin
writeln('Mining copper ore.');
RockColor[0]:=0;
RockColor[1]:=0;
RockColor[2]:=0;
RockColor[3]:=0;
end;
// begin not needed
if(not(LoggedIn)) then
Exit;
// else not needed
For i:= 0 to 5 do
for ii:=0 to 3 do // this is needed to stop a out of range error as there are only 4 RockColors
if(FindObjCustom(x,y,['ine','in','ne','ocks','ock'],[RockColor[ii]],6)) then // missing a closing bracket
begin
if IsUpText('ocks') then
begin
MineRocks;
end;
end;
end;

begin
SetupMineRocks;
end.

i would suggest breaking it up into smaller procedures like a LoadRock, also learning about cases would help

something like this
procedure LoadRockRecord;
var
RockColor: array[0..3] of integer;

begin
case Lowercase(RockType) of
//case Lowercase(Players[CurrentPlayer].Strings[0]) of // i would suggest uing something like this so you only have to use
// this proc once at the beggining of your script
'iron':
begin
RockColor := [0, 1, 2, 3]; // put rock colours here
end;

'tin':
begin
RockColor := [0, 1, 2, 3];
end;


// etc for each rock
end;
end;

also your standards are a little bit off, its no big deal but it makes it alot easier to read and you can find little errors like an extra begin/end somewhere

i hope this helps a little

i luffs yeww

2011-02-08 01:26:42

Or, if you want help from people on irc on how to get on irc, https://qchat.rizon.net, channel is #srl, choose whatever nick you want, and there's no auth/password. Once you're on, ask how to register a nick and blah blah blah, if you so please.

BraK

2011-02-08 01:29:37

Some additional reading to improve on this would be a tutorial on Cases.

~BraK