Template:API: Difference between revisions

From Spring
Jump to navigationJump to search
Smoth (talk | contribs)
No edit summary
Flozi (talk | contribs)
draft #1
Line 1: Line 1:
<includeonly><span style="color:#cccccc;text-shadow: #111 2px 2px 2px;">{{{1}}}'''{{anchor|API:{{{2}}}}}{{{2}}}'''({{{3}}})</span>
<includeonly>{{prefix|{{{prefix}}}}}{{name|{{{name}}}}}{{var|1=({{{args}}})}}
: <span style="color:#E6F08C">{{{4}}}</span>


: {{{5}}}</includeonly><noinclude>
{{#if: {{{return|}}}|return: {{var|1={{{return}}}}}|}}
{{FIXME}}Usage old colour <nowiki></span><span style="color:#00ff88"></nowiki></noinclude>
{{#if: {{{output|}}}|{{var|1=-> {{{output}}}}}|}}
 
:{{{info}}}
</includeonly><noinclude>
 
{{API
|prefix = Spring
|name = UseTeamResource
|args = {{type|number}} teamID, {{type|string}} {{value|"metal"}} {{pipe}} {{value|"energy"}}, {{type|number}} amount {{pipe}} { metal = {{type|number}} amount, energy = {{type|number}} amount }
|output = {{type|nil}} {{pipe}} {{type|bool}} hadEnough
|info = Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.
}}
 
<pre>
{{API <!-- Callout example -->
|prefix = Spring
|name = UseTeamResource
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} "metal" {{pipe}} "energy"
|arg3 = {{type|number}} amount {{pipe}} { metal = {{type|number}} amount, energy = {{type|number}} amount }
|output = {{type|nil}} {{pipe}} {{type|bool}} hadEnough
|info = Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.
}}</pre>
 
{{prefix|Spring.}}{{name|UseTeamResource}}{{var|1=({{type|number}} teamID, {{type|string}} {{value|"metal"}} {{pipe}} {{value|"energy"}}, {{type|number}} amount {{pipe}} { metal = {{type|number}} amount, energy = {{type|number}} amount })}}
 
{{var|-> {{type|nil}} {{pipe}} {{type|bool}} hadEnough}}
 
:Deduct the specified amount from the team's metal or energy resource.
 
vs.
 
<pre>
{{API <!-- Callin example -->
|prefix = addon <!-- May use gadget: instead? -->
|name = AllowUnitTransfer
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} unitDefID
|arg3 = {{type|number}} oldTeam
|arg4 = {{type|number}} newTeam
|arg5 = {{type|bool}} capture
|return = {{type|bool}} allow <!-- note that this is a different entry than output above -->
|info = Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.
}}</pre>
 
 
{{prefix|addon.}}{{name|AllowUnitTransfer}}{{var|1=({{type|number}} unitID, {{type|number}} unitDefID, {{type|number}} oldTeam,
{{type|number}} newTeam, {{type|bool}} capture)}}
 
return: {{var|{{type|bool}} allow}}
 
:Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.</noinclude>

Revision as of 22:30, 16 June 2016


SpringUseTeamResource(number teamID, string "metal" | "energy", number amount | { metal = number amount, energy = number amount })


-> nil | bool hadEnough

Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.


{{API <!-- Callout example -->
|prefix = Spring
|name = UseTeamResource
|arg1 = {{type|number}} teamID
|arg2 = {{type|string}} "metal" {{pipe}} "energy"
|arg3 = {{type|number}} amount {{pipe}} { metal = {{type|number}} amount, energy = {{type|number}} amount }
|output = {{type|nil}} {{pipe}} {{type|bool}} hadEnough
|info = Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.
}}

Spring.UseTeamResource(number teamID, string "metal" | "energy", number amount | { metal = number amount, energy = number amount })

-> nil | bool hadEnough

Deduct the specified amount from the team's metal or energy resource.

vs.

{{API <!-- Callin example -->
|prefix = addon <!-- May use gadget: instead? -->
|name = AllowUnitTransfer
|arg1 = {{type|number}} unitID
|arg2 = {{type|number}} unitDefID
|arg3 = {{type|number}} oldTeam
|arg4 = {{type|number}} newTeam
|arg5 = {{type|bool}} capture
|return = {{type|bool}} allow <!-- note that this is a different entry than output above -->
|info = Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.
}}


addon.AllowUnitTransfer(number unitID, number unitDefID, number oldTeam, number newTeam, bool capture)

return: bool allow

Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.