Resource:Battlefield/getSquad: Difference between revisions
Jump to navigation
Jump to search
LeetWoovie (talk | contribs) No edit summary |
LeetWoovie (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
This command retrieves a squad element when given the name or | __NOTOC__ | ||
==Purpose== | |||
This command retrieves a [[Resource:Battlefield/squad|squad]] element when given the name or [[Resource:Battlefield/shortname|shortname]] of a squad and the team. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
squad getSquad ( [string squadName, string | squad getSquad ( [string squadName, string squadShortn], team squadTeam ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Resource:Battlefield]] | ===Required Arguments=== | ||
*'''squadTeam:''' The [[team]] element the squad will be attached to. | |||
===Optional Arguments=== | |||
*'''squadName:''' The name of the squad. | |||
*'''squadShortn:''' The shortname of the squad. | |||
===Returns=== | |||
Returns the ''squad element'' if it was found, otherwise ''false''. | |||
==Function Source== | |||
<syntaxhighlight lang="lua"> | |||
nameTable = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel" } | |||
shortnTable = { "a", "b", "c", "d", "e", "f", "g", "h" } | |||
function getSquad ( name, team ) | |||
local squads = getElementsByType ( "squad" ) | |||
for k,v in ipairs ( squads ) do | |||
local sTeam = getElementData ( v, "team" ) | |||
if team == sTeam then | |||
for j,l in ipairs ( nameTable ) do | |||
if name == l then | |||
return v | |||
else | |||
for u,p in ipairs ( shortnTable ) do | |||
if name == p then | |||
return v | |||
else | |||
return false | |||
end | |||
end | |||
end | |||
else | |||
return false | |||
end | |||
end | |||
end | |||
</syntaxhighlight> | |||
{| width="100%" style="text-align:left; background-color:#F9F9F9; border:1px solid #AAAAAA;" | |||
| [[Resource:Battlefield|Return to Battlefield Resource]] | |||
|} |
Revision as of 14:45, 22 April 2010
Purpose
This command retrieves a squad element when given the name or shortname of a squad and the team.
Syntax
squad getSquad ( [string squadName, string squadShortn], team squadTeam )
Required Arguments
- squadTeam: The team element the squad will be attached to.
Optional Arguments
- squadName: The name of the squad.
- squadShortn: The shortname of the squad.
Returns
Returns the squad element if it was found, otherwise false.
Function Source
nameTable = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel" } shortnTable = { "a", "b", "c", "d", "e", "f", "g", "h" } function getSquad ( name, team ) local squads = getElementsByType ( "squad" ) for k,v in ipairs ( squads ) do local sTeam = getElementData ( v, "team" ) if team == sTeam then for j,l in ipairs ( nameTable ) do if name == l then return v else for u,p in ipairs ( shortnTable ) do if name == p then return v else return false end end end else return false end end end
Return to Battlefield Resource |