PDA

View Full Version : Function DefineLoopDuration



Jackrawl
12-05-2007, 01:32 AM
function DefineLoopDuration: integer;
begin
for I:=0 to HowManyPlayers-1 do
begin
writeln(Players[I].Name + inttostr(Players[I].Integers[0]));
Result := Result + Players[I].Integers[0];
Definition := Result;
end;
Writeln('This loop shall run for '+inttostr(Result) + ' loads over ' +
inttostr(howmanyplayers) + ' players');
end;This works, except I would like to know how I could get it to say the player's name.

Santa_Clause
12-05-2007, 05:36 AM
function DefineLoopDuration: integer;
begin
for I:=0 to HowManyPlayers-1 do
begin
WriteLn(Players[I].Name + IntToStr(Players[I].Integers[0]));
Result := Result + Players[I].Name + Players[I].Integers[0];
Definition := Result;
end;
Writeln('This loop shall run for '+ IntToStr(Result) + ' loads over ' + IntToStr(HowManyPlayers) + ' players');
end;


There.

n3ss3s
12-05-2007, 02:06 PM
Not trying to attack your function, but whats the usage except for telling the user how many loads in total there will be?

Jackrawl
12-05-2007, 04:29 PM
If you put in 'Until x = Definition' then it will go through the loop until x =...well, definition. The writeln tells the person how long the loop will run, and how many per character, just so they feel safe and my function looks bigger.

Yours doesn't compile for me Santa. "Type mismatch"

And the thing that I want to change is in writeln anyway.
(Oh yes, and you have to put this in declareplayers.)
procedure DeclarePlayers;
begin
HowManyPlayers := 5;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
Players[0].Loc := 'Bank'
Players[0].Integers[0] := 5 //Loads for this character to do

Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Active := False;
Players[1].Loc := 'Bank'
Players[1].Integers[0] := 5 //Loads for this character to do

Players[2].Name := '';
Players[2].Pass := '';
Players[2].Nick := '';
Players[2].Active := False;
Players[2].Loc := 'Bank'
Players[2].Integers[0] := 5 //Loads for this character to do

Players[3].Name := '';
Players[3].Pass := '';
Players[3].Nick := '';
Players[3].Active := False;
Players[3].Loc := 'Bank'
Players[3].Integers[0] := 5 //Loads for this character to do

Players[4].Name := '';
Players[4].Pass := '';
Players[4].Nick := '';
Players[4].Active := False;
Players[4].Loc := 'Bank'
Players[4].Integers[0] := 5 //Loads for this character to do

DefineLoopDuration;
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
Right now the debug box gives me
5
5
5
5
5
This loop shall run for 25 loads over 5 players
0
Error detecting Compass Angle.
Successfully executed
Which I want to say
(Name) 5
(Name) 5
(Name) 5
(Name) 5
(Name) 5
This loop shall run for 25 loads over 5 players
0
Error detecting Compass Angle.
Successfully executed
Also, I know this is very basic, but it will help in anything using multiplayer and integers[0] because it sets the loops length for the people after they say how many loads on each individual character.

Naum
12-05-2007, 07:23 PM
(Name) 5
(Name) 5
(Name) 5
(Name) 5
(Name) 5
This loop shall run for 25 loads over 5 players
Writeln('One Player = '+IntTostr(Players[CurrentPlayer].Integers[0]' Loads!+' Loads)<--- :p
Error detecting Compass Angle.
Successfully executed

Could try this :p

Narcle
12-05-2007, 07:58 PM
function DefineLoopDuration: integer;
begin
for I:=0 to HowManyPlayers-1 do
begin
WriteLn(Players[i].Name + IntToStr(Players[i].Integers[0]));
Result := Result + Players[i].Integers[0];
Definition := Result;
end;
Writeln('This loop shall run for '+ IntToStr(Result) + ' loads over ' + IntToStr(HowManyPlayers) + ' players');
end;

Try that, Santa put the name in result for some odd reason. (noob)

Santa_Clause
12-05-2007, 10:55 PM
I think I posted the answer to your question on another thread...

Narcle
12-05-2007, 11:28 PM
I saw that, I was wondering why you posted it in his other thread.

Jackrawl
12-05-2007, 11:56 PM
Oh what the heck! Mine was right to begin with, the reason it wasn't giving you the player name was because the multiplayer I was using was blank!
OK, so the one that works best is
Procedure DefineLoopDuration;
begin
for I:=0 to HowManyPlayers-1 do
begin
writeln(Players[i].Name + ' ' + inttostr(Players[i].Integers[0]));
Result := Result + Players[i].Integers[0];
Definition := Result;
end;
Writeln('This loop shall run for '+inttostr(Result) + ' loads over ' +
inttostr(howmanyplayers) + ' players');
end;
...lol ( <------ Dumb)
Edit: Looking back, how is this a function to begin with?..Fixing it.