User:Flozi: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
→Template:API proposal: check how ugly this style is with something with long params list like CreateUnit (ugly :( )
Flozi (talk | contribs)
→Template:API proposal: or use syntaxhighlight with c ?
Line 22: Line 22:


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


{{prefix|Spring.}}{{name|CreateUnit}}{{var|1=( {{type|string}} "defName" {{pipe}} number unitDefID, {{type|number}} x, {{type|number}} y, {{type|number z}},
{{prefix|Spring.}}{{name|CreateUnit}}{{var|1=( {{type|string}} "defName" {{pipe}} number unitDefID, {{type|number}} x, {{type|number}} y, {{type|number z}},
Line 54: Line 53:


:Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.
:Called just before a unit is transferred to a different team, the boolean return value determines whether or not the transfer is permitted.
=== Using syntaxhighlight instead ===
<syntaxhighlight lang="c">Spring.CreateUnit // offmap positions are clamped! (you still can use MoveCtrl todo so)
( string "defName" | int unitDefID,
  int x, int y, int z,
  (int facing | string "facing"),
  int teamID
  [, bool build = false]
  [, bool flattenGround = true]
  [, int unitID]
  [, int builderID]) -> int unitID | nil</syntaxhighlight>


= TODO: =
= TODO: =

Revision as of 23:51, 5 January 2018

My User Subpages

Scratchpad

Template:API proposal

Note that the number of 'arg1' etc is fixed (i.e. 10) but can be omitted without issue. the 'type' template is just a way to make inserting different styles within the param list easier, Template:Pipe already exists and is required as it is a special char within mediawiki syntax, could use {{!}} as a shorter alternative to pipe.

{{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.

Spring.CreateUnit( string "defName" | number unitDefID, number x, number y, number z, (number facing | string "facing"), number teamID [, boolean build = false] [, boolean flattenGround = true] [, number unitID] [, number builderID ])

-> number unitID | nil

{{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.

Using syntaxhighlight instead

<syntaxhighlight lang="c">Spring.CreateUnit // offmap positions are clamped! (you still can use MoveCtrl todo so)

( string "defName" | int unitDefID,
  int x, int y, int z,
  (int facing | string "facing"),
  int teamID
  [, bool build = false] 
  [, bool flattenGround = true]
  [, int unitID]
  [, int builderID]) -> int unitID | nil</syntaxhighlight>

TODO:

Major

Minor

Undocumented Features