User:Flozi: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
testing
Flozi (talk | contribs)
 
(38 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Lua Callin example:''' <pre>{{luacallin|wudget|name|param_list|return_list|description}}</pre>
= My User Subpages =
{{Special:PrefixIndex/User:Flozi/}}


<span style="color:#cccccc;text-shadow: #111 2px 2px 2px;">gadget:'''AllowUnitCreation'''</span>
= Scratchpad =


<span style="color:#00ff88">( number unitDefID, number builderID, number builderTeam,  
== Template:API proposal ==
<br/>number x, number y, number z,
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 <nowiki>{{!}}</nowiki> as a shorter alternative to pipe.
<br/>number facing )</span>  
<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>


<span style="color:#ffff88">return: bool allow</span>
{{prefix|Spring.}}{{name|[[#UseTeamResource|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 })}}


Called just before unit is created, the boolean return value determines whether or not the creation is permitted.
{{var|-> {{type|nil}} {{pipe}} {{type|bool}} hadEnough}}


: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}},
({{type|number}} facing {{pipe}} {{type|string}} "facing"),
{{type|number}} teamID
[, {{type|boolean}} build = {{value|false}}]
[, {{type|boolean}} flattenGround = {{value|true}}]
[, {{type|number}} unitID]
[, {{type|number}} builderID ])}}


'''Lua Callout example:'''<pre>{{luacallout|parent_table|name|param_list|return_list|description}}</pre>
{{var|-> {{type|number}} unitID {{pipe}} {{type|nil}}}}


<span style="color:#cccccc;text-shadow: #111 2px 2px 2px;">Spring.'''UseTeamResource'''</span>  
<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>


<span style="color:#00ff88">( number teamID,
<br/>  string "metal" &#124; "energy", number amount &#124;
<br/>  { metal = number amount, energy = number amount} )


<span style="color:#ffff88">-> nil &#124; bool hadEnough</span>
{{prefix|addon.}}{{name|AllowUnitTransfer}}{{var|1=({{type|number}} unitID, {{type|number}} unitDefID, {{type|number}} oldTeam,
{{type|number}} newTeam, {{type|bool}} capture)}}


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.
return: {{var|{{type|bool}} allow}}


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


{{LuaCallin
=== Using syntaxhighlight instead ===
|addon = {widget, gadget}
|name = Initialize
|params =  
|return = none
|description = Called when the addon is (re)loaded.
}}


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


{{LuaCallin
= TODO: =
|addon = {widget, gadget}
|name = Shutdown
|params =
|return = none
|description = Called when the addon or the game is shutdown.
}}


==Major==
* [[:Category:ShowCase]] template, main page, S44 & MCL as examples
* [[:Category:Tutorial]]
* Continue to improve [[Lua:Callins]] - Fill in blank explanations
* Clickable / right-click copy paste-able anchors in <nowiki>{{tag}}</nowiki> et al
* [[Assimp]] build upon, metadata doc, split tutorial again >_>
* Cleanup old [[:Category:Map_making]] into new [[:Category:Map Dev]]


{{LuaCallin
==Minor==
|addon = {widget, gadget}
* Page on spring wiki etiquette ([[SpringWiki]]) / style guide & template usage ([[Mapdev:WikiGuide]]) /namespace conventions ([[Spring:PageNamingConventions]]) - pages are good already; put these in revamped community portal?
|name = PlayerChanged
* Move all pages in [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation-&namespace=0 Animation-] to [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation%3A&namespace=0 Animation:]
|params = number playerID
* Continue to improve [[Gamedev:Main]] up to the high standard of [[Mapdev:Main]]
|return = none
|description = Called whenever a player's status changes e.g. becoming a spectator.
}}
<hr/>
'''TODO:'''


Revamp [[LuaCallinReturn]]
==Undocumented Features==
 
* cmdcolors.txt (c.f. {{forumlink|topic=7099|title=GUI modifications in SVN}})
Complete [[Spring:SiteMapThoughts]]
* ctrlpanel.txt (c.f. as above)
 
* isolated mode (isolated.txt 99+ c.f. {{forumlink|topic=26359|title=portable/isolation mode}}, [http://springrts.com/dl/buildbot/default/master/99.0/manpages/spring.6.html Spring manpages])
[[OTAism]]
 
Page on spring wiki etiquette / style guide / template usage /namespace conventions ( [[Spring:PageNamingConventions]] )
 
Move all pages in [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Units-&namespace=0 Units-] to [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Units%3A&namespace=0 Units:]

Latest revision as of 19:26, 28 March 2020

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