Difference between revisions of "TPlayers.Add"
Line 1: | Line 1: | ||
− | '''''function | + | '''''function Add(NewPlayer: [[TNewPlayer]]): [[TActivePlayer]]''''' |
− | + | NewPlayer: An instance of TNewPlayer serving as configuration object for the bot | |
− | Result: | + | Result: Active instance of bot |
==Description== | ==Description== | ||
− | + | Adds a new bot to game basing on configuration from [[TNewPlayer]]. | |
− | + | '''Don't forget to free TNewPlayer instance after using it!''' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Example == | == Example == | ||
− | <syntaxhighlight lang="pascal"> | + | <syntaxhighlight lang="pascal"> |
− | begin | + | var |
− | + | NewPlayer: TNewPlayer; | |
− | + | begin | |
− | + | NewPlayer := TNewPlayer.Create; | |
− | + | try | |
− | end; | + | NewPlayer.Name := 'Test bot!'; |
+ | NewPlayer.Team := 1; // important! | ||
+ | NewPlayer.PantsColor := $FFFFFFFF; | ||
+ | NewPlayer.SkinColor := $FFFFFFFF; | ||
+ | Players.Add(NewPlayer); | ||
+ | finally | ||
+ | NewPlayer.Free; // important! | ||
+ | end; | ||
+ | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | [[Category: | + | [[Category:TPlayers]] |
Revision as of 15:15, 26 July 2013
function Add(NewPlayer: TNewPlayer): TActivePlayer NewPlayer: An instance of TNewPlayer serving as configuration object for the bot Result: Active instance of bot
Description
Adds a new bot to game basing on configuration from TNewPlayer. Don't forget to free TNewPlayer instance after using it!
Example
var
NewPlayer: TNewPlayer;
begin
NewPlayer := TNewPlayer.Create;
try
NewPlayer.Name := 'Test bot!';
NewPlayer.Team := 1; // important!
NewPlayer.PantsColor := $FFFFFFFF;
NewPlayer.SkinColor := $FFFFFFFF;
Players.Add(NewPlayer);
finally
NewPlayer.Free; // important!
end;
end;