Template:LuaCallout: Difference between revisions

From Spring
Jump to navigationJump to search
Adapted the API template to feature a readable code for the respective function arguments
m Added description
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
{{#if: {{{arg5}}} | {{{arg5}}} | }}{{#if: {{{arg6}}} |, | }}
{{#if: {{{arg5}}} | {{{arg5}}} | }}{{#if: {{{arg6}}} |, | }}
{{#if: {{{arg6}}} | {{{arg6}}} | }}{{#if: {{{arg7}}} |, | }}
{{#if: {{{arg6}}} | {{{arg6}}} | }}{{#if: {{{arg7}}} |, | }}
{{#if: {{{arg7}}} | {{{arg7}}} | }}{{#if: {{{arg8}}} |, | }}
{{#if: {{{arg8}}} | {{{arg8}}} | }}{{#if: {{{arg9}}} |, | }}
{{#if: {{{arg8}}} | {{{arg8}}} | }}{{#if: {{{arg9}}} |, | }}
{{#if: {{{arg9}}} | {{{arg9}}} | }}  
{{#if: {{{arg9}}} | {{{arg9}}} | }}  
}} )
}} )
{{#if: {{{return|}}}|<br>return: {{var|1={{{return}}}}}|}}
{{#if: {{{return|}}}|<br>return: {{var|1={{{return}}}}}|}}
:{{#if: {{{info|}}} | <br>{{{info}}} | }}</includeonly><noinclude>
:{{#if: {{{info|}}} | {{{info}}} | }}</includeonly><noinclude>


==Lua Callout usage example==
==Lua Callout usage example==
This template creates an anchored entry meant for Lua functions. It allows for a function prefix, funtion name, up to 9 function argument slots, info about the returned variable(s) and a description.


<pre>
<pre>

Latest revision as of 22:19, 28 February 2021


Lua Callout usage example

This template creates an anchored entry meant for Lua functions. It allows for a function prefix, funtion name, up to 9 function argument slots, info about the returned variable(s) and a description.

{{LuaCallout
|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 } 
|arg4 =
|arg5 =
|arg6 =
|arg7 =
|arg8 =
|arg9 =
|return = {{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 } )
return: 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.