Difference between revisions of "Template:Function2"

From Kolmafia
Jump to navigation Jump to search
Line 3: Line 3:
 
==Function Syntax==
 
==Function Syntax==
 
{{#if: {{{function1.return_type|}}}
 
{{#if: {{{function1.return_type|}}}
   |{{User:Philmasterplus/FunctionDeclaration
+
   |<p>{{FunctionDeclaration|name={{{name}}}|func=1|desc=yes}}</p>}}
    |name={{{name}}}
 
    |return_type={{{function1.return_type}}}
 
    |param1={{{function1.param1|}}}
 
    |param1.type={{{function1.param1.type|}}}
 
    |param1.optional={{{function1.param1.optional|}}}
 
    |param1.default={{{function1.param1.default|}}}
 
    |param2={{{function1.param2|}}}
 
    |param2.type={{{function1.param2.type|}}}
 
    |param2.optional={{{function1.param2.optional|}}}
 
    |param2.default={{{function1.param2.default|}}}
 
    |param3={{{function1.param3|}}}
 
    |param3.type={{{function1.param3.type|}}}
 
    |param3.optional={{{function1.param3.optional|}}}
 
    |param3.default={{{function1.param3.default|}}}
 
    |param4={{{function1.param4|}}}
 
    |param4.type={{{function1.param4.type|}}}
 
    |param4.optional={{{function1.param4.optional|}}}
 
    |param4.default={{{function1.param4.default|}}}
 
    |param5={{{function1.param5|}}}
 
    |param5.type={{{function1.param5.type|}}}
 
    |param5.optional={{{function1.param5.optional|}}}
 
    |param5.default={{{function1.param5.default|}}}
 
  }}
 
  {{#if: {{{function1.param1|}}}
 
    |<ul><li>'''{{{function1.param1.type}}} {{Pspan|{{{function1.param1}}}}}''': {{{function1.param1.description}}}</li>
 
    {{#if: {{{function1.param2|}}}
 
      |<li>'''{{{function1.param2.type}}} {{Pspan|{{{function1.param2}}}}}''': {{{function1.param2.description}}}</li>}}
 
    {{#if: {{{function1.param3|}}}
 
      |<li>'''{{{function1.param3.type}}} {{Pspan|{{{function1.param3}}}}}''': {{{function1.param3.description}}}</li>}}
 
    {{#if: {{{function1.param4|}}}
 
      |<li>'''{{{function1.param4.type}}} {{Pspan|{{{function1.param4}}}}}''': {{{function1.param4.description}}}</li>}}
 
    {{#if: {{{function1.param5|}}}
 
      |<li>'''{{{function1.param5.type}}} {{Pspan|{{{function1.param5}}}}}''': {{{function1.param3.description}}}</li>}}
 
    </ul>
 
  }}{{#if: {{{function1.short_description|}}}|: {{{function1.short_description}}}}}
 
}}
 
 
{{#if: {{{function2.return_type|}}}
 
{{#if: {{{function2.return_type|}}}
   |{{User:Philmasterplus/FunctionDeclaration
+
   |<p>{{FunctionDeclaration|name={{{name}}}|func=2|desc=yes}}</p>}}
    |name={{{name}}}
 
    |return_type={{{function2.return_type}}}
 
    |param1={{{function2.param1|}}}
 
    |param1.type={{{function2.param1.type|}}}
 
    |param1.optional={{{function2.param1.optional|}}}
 
    |param1.default={{{function2.param1.default|}}}
 
    |param2={{{function2.param2|}}}
 
    |param2.type={{{function2.param2.type|}}}
 
    |param2.optional={{{function2.param2.optional|}}}
 
    |param2.default={{{function2.param2.default|}}}
 
    |param3={{{function2.param3|}}}
 
    |param3.type={{{function2.param3.type|}}}
 
    |param3.optional={{{function2.param3.optional|}}}
 
    |param3.default={{{function2.param3.default|}}}
 
    |param4={{{function2.param4|}}}
 
    |param4.type={{{function2.param4.type|}}}
 
    |param4.optional={{{function2.param4.optional|}}}
 
    |param4.default={{{function2.param4.default|}}}
 
    |param5={{{function2.param5|}}}
 
    |param5.type={{{function2.param5.type|}}}
 
    |param5.optional={{{function2.param5.optional|}}}
 
    |param5.default={{{function2.param5.default|}}}
 
  }}
 
  {{#if: {{{function2.param1|}}}
 
    |<ul><li>'''{{{function2.param1.type}}} {{Pspan|{{{function2.param1}}}}}''': {{{function2.param1.description}}}</li>
 
    {{#if: {{{function2.param2|}}}
 
      |<li>'''{{{function2.param2.type}}} {{Pspan|{{{function2.param2}}}}}''': {{{function2.param2.description}}}</li>}}
 
    {{#if: {{{function2.param3|}}}
 
      |<li>'''{{{function2.param3.type}}} {{Pspan|{{{function2.param3}}}}}''': {{{function2.param3.description}}}</li>}}
 
    {{#if: {{{function2.param4|}}}
 
      |<li>'''{{{function2.param4.type}}} {{Pspan|{{{function2.param4}}}}}''': {{{function2.param4.description}}}</li>}}
 
    {{#if: {{{function2.param5|}}}
 
      |<li>'''{{{function2.param5.type}}} {{Pspan|{{{function2.param5}}}}}''': {{{function2.param3.description}}}</li>}}
 
    </ul>
 
  }}{{#if: {{{function2.short_description|}}}|: {{{function2.short_description}}}}}
 
}}
 
 
{{#if: {{{function3.return_type|}}}
 
{{#if: {{{function3.return_type|}}}
   |{{User:Philmasterplus/FunctionDeclaration
+
   |<p>{{FunctionDeclaration|name={{{name}}}|func=3|desc=yes}}</p>}}
    |name={{{name}}}
+
{{#if: {{{function4.return_type|}}}
    |return_type={{{function3.return_type}}}
+
  |<p>{{FunctionDeclaration|name={{{name}}}|func=4|desc=yes}}</p>}}
    |param1={{{function3.param1|}}}
+
{{#if: {{{function5.return_type|}}}
    |param1.type={{{function3.param1.type|}}}
+
  |<p>{{FunctionDeclaration|name={{{name}}}|func=5|desc=yes}}</p>}}
    |param1.optional={{{function3.param1.optional|}}}
+
{{{description}}}
    |param1.default={{{function3.param1.default|}}}
 
    |param2={{{function3.param2|}}}
 
    |param2.type={{{function3.param2.type|}}}
 
    |param2.optional={{{function3.param2.optional|}}}
 
    |param2.default={{{function3.param2.default|}}}
 
    |param3={{{function3.param3|}}}
 
    |param3.type={{{function3.param3.type|}}}
 
    |param3.optional={{{function3.param3.optional|}}}
 
    |param3.default={{{function3.param3.default|}}}
 
    |param4={{{function3.param4|}}}
 
    |param4.type={{{function3.param4.type|}}}
 
    |param4.optional={{{function3.param4.optional|}}}
 
    |param4.default={{{function3.param4.default|}}}
 
    |param5={{{function3.param5|}}}
 
    |param5.type={{{function3.param5.type|}}}
 
    |param5.optional={{{function3.param5.optional|}}}
 
    |param5.default={{{function3.param5.default|}}}
 
  }}
 
  {{#if: {{{function3.param1|}}}
 
    |<ul><li>'''{{{function3.param1.type}}} {{Pspan|{{{function3.param1}}}}}''': {{{function3.param1.description}}}</li>
 
    {{#if: {{{function3.param2|}}}
 
      |<li>'''{{{function3.param2.type}}} {{Pspan|{{{function3.param2}}}}}''': {{{function3.param2.description}}}</li>}}
 
    {{#if: {{{function3.param3|}}}
 
      |<li>'''{{{function3.param3.type}}} {{Pspan|{{{function3.param3}}}}}''': {{{function3.param3.description}}}</li>}}
 
    {{#if: {{{function3.param4|}}}
 
      |<li>'''{{{function3.param4.type}}} {{Pspan|{{{function3.param4}}}}}''': {{{function3.param4.description}}}</li>}}
 
    {{#if: {{{function3.param5|}}}
 
      |<li>'''{{{function3.param5.type}}} {{Pspan|{{{function3.param5}}}}}''': {{{function3.param3.description}}}</li>}}
 
    </ul>
 
  }}{{#if: {{{function3.short_description|}}}|: {{{function3.short_description}}}}}
 
}}
 
 
{{#if: {{{code1|}}}|{{{code1}}}}}{{#if: {{{code2|}}}|{{{code2}}}}}{{#if: {{{code3|}}}|{{{code3}}}}}{{#if: {{{code4|}}}|{{{code4}}}}}{{#if: {{{code5|}}}|{{{code5}}}}}
 
{{#if: {{{code1|}}}|{{{code1}}}}}{{#if: {{{code2|}}}|{{{code2}}}}}{{#if: {{{code3|}}}|{{{code3}}}}}{{#if: {{{code4|}}}|{{{code4}}}}}{{#if: {{{code5|}}}|{{{code5}}}}}
 
{{#if: {{{cli_equiv|}}}|
 
{{#if: {{{cli_equiv|}}}|
Line 140: Line 37:
 
       "example": "visit_url"
 
       "example": "visit_url"
 
     },
 
     },
     "function1.short_description": {
+
     "function1.description": {
       "label": "Function 1, short description",
+
       "label": "Function 1, description",
 
       "description": "Short description for the overloaded function 1 (and so on for functions 2 through 3)",
 
       "description": "Short description for the overloaded function 1 (and so on for functions 2 through 3)",
 
       "type": "content",
 
       "type": "content",
Line 183: Line 80:
 
==Examples==
 
==Examples==
 
<pre>{{User:Philmasterplus/TemplateSandbox2
 
<pre>{{User:Philmasterplus/TemplateSandbox2
|name=visit_url
+
|name=User:Philmasterplus/Sandbox
 
|function1.return_type=buffer
 
|function1.return_type=buffer
 
|function1.short_description=Returns the original HTML source of the page being overridden inside a relay override script.
 
|function1.short_description=Returns the original HTML source of the page being overridden inside a relay override script.
Line 208: Line 105:
  
 
{{User:Philmasterplus/TemplateSandbox2
 
{{User:Philmasterplus/TemplateSandbox2
|name=visit_url
+
|name=User:Philmasterplus/Sandbox
 
|function1.return_type=buffer
 
|function1.return_type=buffer
 
|function1.short_description=Returns the original HTML source of the page being overridden inside a relay override script.
 
|function1.short_description=Returns the original HTML source of the page being overridden inside a relay override script.

Revision as of 09:51, 20 December 2020

Replacement for Template:FunctionPage. Must be used with function pages that follow a specific format.

Template parameters

ParameterDescriptionTypeStatus
ASH function namename

Name of the ASH function. This should match the function page name.

Example
visit_url
Linerequired
Function 1, descriptionfunction1.description

Short description for the overloaded function 1 (and so on for functions 2 through 3)

Example
Visits a web page and returns its HTML source.
Contentoptional
Function 1, return typefunction1.return_type

Return type of the overloaded function 1.

Example
buffer
Linerequired
Function 1, parameter 1function1.param1

Name of the parameter 1 of the overloaded function 1 (and so on for parameters 2 through 5).

Example
url
Lineoptional
Function 1, parameter 1 descriptionfunction1.param1.description

Description of parameter 1 of the overloaded function 1.

Example
URL of the page to visit. If a relative URL is provided, it is treated as an in-game page.
Contentoptional
Function 1, parameter 1 is optional?function1.param1.optional

"yes" = optional. Any non-empty string will do, but please use "yes" to make standardization easier.

Example
yes
Lineoptional
Function 1, parameter 1 default valuefunction1.param1.default

If this is specified, function1.param1.optional must be "yes"

Example
""
Lineoptional

Examples

{{User:Philmasterplus/TemplateSandbox2
|name=User:Philmasterplus/Sandbox
|function1.return_type=buffer
|function1.short_description=Returns the original HTML source of the page being overridden inside a relay override script.
|function1.description=Returns the original HTML source of the page being overridden. ''This function works only inside a relay override script.''
|function2.return_type=buffer
|function2.short_description=Visits a web page and returns its HTML source.
|function2.description=Makes an HTTP request to a web page and returns its HTML source.
|function2.param1=url
|function2.param1.type=string
|function2.param1.optional=yes
|function2.param1.default=""
|function2.param1.description=URL of the page to visit. If a relative URL is provided, it is treated as an in-game page.
|function2.param2=use_POST
|function2.param2.type=boolean
|function2.param2.optional=yes
|function2.param2.default=true
|function2.param2.description=If <code>true</code>, makes an HTTP POST request when visiting the URL. Otherwise, makes a GET request.
|function2.param3=encoded
|function2.param3.type=boolean
|function2.param3.optional=yes
|function2.param3.default=false
|function2.param3.description=If <code>true</code>, KoLmafia assumes that <code>url</code> has already been [[wikipedia:Percent-encoding|URL-encoded]] and will not encode it.
}}


Function Syntax

Nothing to see here, move along. Nothing to see here, move along.( Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along. )

Nothing to see here, move along.

Nothing to see here, move along. Nothing to see here, move along.( Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along., Nothing to see here, move along.? Nothing to see here, move along. = Nothing to see here, move along. )

Nothing to see here, move along.

{{{description}}}