SRL Archive - OSR Help

Booleans[0] help


RISK

2010-08-02 19:53:05

Alright, so I was playing around with coding, trying to learn some of the new recommended stuff since I've been gone for a while due to real life stuff.
I decided to try the 'Booleans[0]' thing for DeclarePlayers;. But when I try to use it in an If statement, it won't work for some reason. I'm using them on line 48 and 53, by the way.

Am I missing something here? Or am I just using it wrong? It gives me this error:

[Error] (49:18): Unknown identifier 'Booleans' at line 48
Compiling failed.



program New;
{$i SRL/SRl.scar}

var X, Y : Integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Booleans[0] := False; // Powerchopping = False - Banking = True
end;
end;

procedure Antiban;
begin
if not LoggedIn then Exit;

case Random(3042 + Random (601)) of
0 .. 12 : HoverSkill('Woodcutting', False);
13 .. 15 : HoverSkill('Constitution', False);
16 .. 21 : HoverSkill('Fletching', False);
36 .. 54 : begin
case Random(3) of
0 : MakeCompass('N');
1 : MakeCompass('S');
2 : MakeCompass('W');
3 : MakeCompass('E');
end;
end;
103 .. 110 : MouseSpeed := 9 + Random (4);
250 .. 302 : RandomAngle('');
end;
end;

procedure FindAndChopTree;
begin
if not LoggedIn then Exit;

// If our inventory is full and we are powerchopping
if InvFull and Booleans[0] = False then
begin

end else
// If our inventory is full and we are banking
if InvFull and Booleans[0] = True then
begin
end else

end;

begin
end.

Thanks in advance for any help.

Cigue

2010-08-02 19:55:28

As you can see, in the DeclarePlayers procedure, there is a part that goes :
with Players[0] do//HERE
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
end;

This means that the variables are set for Players[0], meaning that you can use Players[0].Booleans[0], Players[0].Pin, Players[0].Nick, etc.

RISK

2010-08-02 20:02:42

Well thanks for the help. But that's not really what I was looking for. What I was looking for was:

If I perhaps wanted to use that Players[0].Booleans in an If statement, what would I have to do? Because it gives me an error every time I try to do:

procedure FindAndChopTree;
begin
if not LoggedIn then Exit;

// If our inventory is full and we are powerchopping
if InvFull and Booleans[0] = False then
begin

end else
// If our inventory is full and we are banking
if InvFull and Booleans[0] = True then
begin
end else

end;

Method

2010-08-02 20:55:55

From: Risk
Well thanks for the help. But that's not really what I was looking for. What I was looking for was:

If I perhaps wanted to use that Players[0].Booleans in an If statement, what would I have to do? Because it gives me an error every time I try to do:

procedure FindAndChopTree;
begin
if not LoggedIn then Exit;

// If our inventory is full and we are powerchopping
if InvFull and Booleans[0] = False then
begin

end else
// If our inventory is full and we are banking
if InvFull and Booleans[0] = True then
begin
end else

end;


Cigue just explained what you would have to do. You have to access the Players array and then the Booleans variable inside that. Those two lines of code could be:

if InvFull and not(Players[CurrentPlayer].Booleans[0])
if InvFull and Players[CurrentPlayer].Booleans[0]

RISK

2010-08-02 21:03:00

Oh, I see. Thank you very much for your help, you two. I really appreciate it. I didn't mean to misunderstand. I just learn better from examples and explanation.