Difference between pages "All normal outfits" and "Template:Function2"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Relyk
(Created page with "{{ #vardefine:name|get_custom_outfits}}{{ #vardefine:return_type|string [int]}}{{ #vardefine:aggregate|yes}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={...")
 
 
Line 1: Line 1:
{{
+
<includeonly>{{TOCright}}{{DISPLAYTITLE:{{{name}}}()}}{{#if: {{{needscode|}}}|{{CodeRequest}}}}{{#if: {{{improvecode|}}}|{{CodeRequest|better=yes}}}}
#vardefine:name|get_custom_outfits}}{{
+
{{#if: {{{name|}}}||{{error|Parameter 'name' is missing for User:Philmasterplus/TemplateSandbox2}}}}
#vardefine:return_type|string [int]}}{{
+
==Function Syntax==
#vardefine:aggregate|yes}}{{
+
{{#if: {{{function1.return_type|}}}
 +
  |<p>{{FunctionDeclaration|name={{{name}}}|func=1|desc=yes}}</p>}}
 +
{{#if: {{{function2.return_type|}}}
 +
  |<p>{{FunctionDeclaration|name={{{name}}}|func=2|desc=yes}}</p>}}
 +
{{#if: {{{function3.return_type|}}}
 +
  |<p>{{FunctionDeclaration|name={{{name}}}|func=3|desc=yes}}</p>}}
 +
{{#if: {{{function4.return_type|}}}
 +
  |<p>{{FunctionDeclaration|name={{{name}}}|func=4|desc=yes}}</p>}}
 +
{{#if: {{{function5.return_type|}}}
 +
  |<p>{{FunctionDeclaration|name={{{name}}}|func=5|desc=yes}}</p>}}
  
FunctionPage|
+
{{{description}}}
name={{#var:name}}|
+
{{#if: {{{code1|}}}|{{{code1}}}}}{{#if: {{{code2|}}}|{{{code2}}}}}{{#if: {{{code3|}}}|{{{code3}}}}}{{#if: {{{code4|}}}|{{{code4}}}}}{{#if: {{{code5|}}}|{{{code5}}}}}
 +
{{#if: {{{cli_equiv|}}}|
 +
==CLI Equivalent==
 +
{{{cli_equiv}}}}}
 +
{{#if: {{{see_also|}}}|{{{see_also|}}}}}
 +
{{#if: {{{more_info|}}}|
 +
==More Information==
 +
{{{more_info}}}}}
 +
{{#if: {{{special|}}}|
 +
==Special==
 +
{{{special}}}}}
 +
[[Category:Ash Functions]]
 +
</includeonly><noinclude>
 +
<templatedata>
 +
{
 +
  "description": "Replacement for Template:FunctionPage. Must be used with function pages that follow a specific format.",
 +
  "params": {
 +
    "name": {
 +
      "label": "ASH function name",
 +
      "description": "Name of the ASH function. This should match the function page name.",
 +
      "required": true,
 +
      "type": "line",
 +
      "example": "visit_url"
 +
    },
 +
    "description": {
 +
      "label": "Description",
 +
      "description": "Long description that covers all functions. Note: Use <p></p> to separate paragraphs, because double line breaks don't work",
 +
      "type": "content"
 +
    },
 +
    "function1.description": {
 +
      "label": "Function 1, description",
 +
      "description": "Short description for the overloaded function 1 (and so on for functions 2 through 3)",
 +
      "type": "content",
 +
      "example": "Visits a web page and returns its HTML source."
 +
    },
 +
    "function1.return_type": {
 +
      "label": "Function 1, return type",
 +
      "description": "Return type of the overloaded function 1.",
 +
      "required": true,
 +
      "type": "line",
 +
      "example": "buffer"
 +
    },
 +
    "function1.param1": {
 +
      "label": "Function 1, parameter 1",
 +
      "description": "Name of the parameter 1 of the overloaded function 1 (and so on for parameters 2 through 5).",
 +
      "type": "line",
 +
      "example": "url"
 +
    },
 +
    "function1.param1.description": {
 +
      "label": "Function 1, parameter 1 description",
 +
      "description": "Description of parameter 1 of the overloaded function 1.",
 +
      "type": "content",
 +
      "example": "URL of the page to visit. If a relative URL is provided, it is treated as an in-game page."
 +
    },
 +
    "function1.param1.optional": {
 +
      "label": "Function 1, parameter 1 is optional?",
 +
      "description": "\"yes\" = optional. Any non-empty string will do, but please use \"yes\" to make standardization easier.",
 +
      "type": "line",
 +
      "example": "yes"
 +
    },
 +
    "function1.param1.default": {
 +
      "label": "Function 1, parameter 1 default value",
 +
      "description": "If this is specified, function1.param1.optional must be \"yes\"",
 +
      "type": "line",
 +
      "example": "\"\""
 +
    }
 +
  }
 +
}
 +
</templatedata>
  
function1={{Function|
+
==Examples==
name={{#var:name}}|
+
<pre>{{User:Philmasterplus/TemplateSandbox2
aggregate={{#var:aggregate}}|
+
|name=User:Philmasterplus/Sandbox
return_type={{#var:return_type}}|
+
|function1.return_type=buffer
return_also={{#var:return_also}}|
+
|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.
 +
|description=
 +
<p>Returns the HTML from the visited page (not just what is displayed when visiting the page, but all markup) by performing a POST request if {{pspan|use_POST}} is omitted or true, or a GET request if false. Note that for addresses inside of KoL, it is only necessary to supply the page name for {{pspan|page}}, and KoLmafia will populate the rest of the url. However, pages outside of KoL require the full url to be supplied for {{pspan|page}}.</p>
  
function_description=This function returns a list of all available in-game outfits.|
+
<p>The version with no parameters is only meaningful in a relay override script; it retrieves the server page that your script is overriding.  All four versions behave slightly differently in a relay script; they retrieve a version of the page with any KoLmafia decorations added, rather than the raw page from the server.</p>
  
code1={{CodeSample|
+
<p>In a POST request, if &pwd is part of the {{pspan|page}} string, it will automatically be replaced by &pwd=###### where ###### is the password hash for the current session. For a GET request the password hash will not be added so you'll want to use {{f|my_hash}}.</p>
title=Code Sample|
+
}}</pre>
description=The following code will print the list of available outfits.|
 
code=<syntaxhighlight>
 
foreach x,outfit_name in all_normal_outfits()
 
  {
 
      print("Outfit: " + outfit_name);
 
      foreach x,piece in outfit_pieces(outfit_name)
 
        print("=> " + piece);
 
  }
 
</syntaxhighlight>
 
}}|
 
  
cli_equiv=The CLI command <code> outfit list </code> will print a list of official KoL outfits to the CLI.|
+
{{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.
 +
|description=
 +
<p>Returns the HTML from the visited page (not just what is displayed when visiting the page, but all markup) by performing a POST request if {{pspan|use_POST}} is omitted or true, or a GET request if false. Note that for addresses inside of KoL, it is only necessary to supply the page name for {{pspan|page}}, and KoLmafia will populate the rest of the url. However, pages outside of KoL require the full url to be supplied for {{pspan|page}}.</p>
  
see_also={{SeeAlso|have_outfit|outfit_pieces|is_wearing_outfit|get_outfits}}|
+
<p>The version with no parameters is only meaningful in a relay override script; it retrieves the server page that your script is overriding.  All four versions behave slightly differently in a relay script; they retrieve a version of the page with any KoLmafia decorations added, rather than the raw page from the server.</p>
 +
 
 +
<p>In a POST request, if &pwd is part of the {{pspan|page}} string, it will automatically be replaced by &pwd=###### where ###### is the password hash for the current session. For a GET request the password hash will not be added so you'll want to use {{f|my_hash}}.</p>
 
}}
 
}}
 
+
</noinclude>
[[Category:Equipment]]
 

Revision as of 10:05, 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
Descriptiondescription

Long description that covers all functions. Note: Use <p></p> to separate paragraphs, because double line breaks don't work

Contentoptional
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.
|description=
<p>Returns the HTML from the visited page (not just what is displayed when visiting the page, but all markup) by performing a POST request if {{pspan|use_POST}} is omitted or true, or a GET request if false. Note that for addresses inside of KoL, it is only necessary to supply the page name for {{pspan|page}}, and KoLmafia will populate the rest of the url. However, pages outside of KoL require the full url to be supplied for {{pspan|page}}.</p>

<p>The version with no parameters is only meaningful in a relay override script; it retrieves the server page that your script is overriding.  All four versions behave slightly differently in a relay script; they retrieve a version of the page with any KoLmafia decorations added, rather than the raw page from the server.</p>

<p>In a POST request, if &pwd is part of the {{pspan|page}} string, it will automatically be replaced by &pwd=###### where ###### is the password hash for the current session. For a GET request the password hash will not be added so you'll want to use {{f|my_hash}}.</p>
}}


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.

Returns the HTML from the visited page (not just what is displayed when visiting the page, but all markup) by performing a POST request if use_POST is omitted or true, or a GET request if false. Note that for addresses inside of KoL, it is only necessary to supply the page name for page, and KoLmafia will populate the rest of the url. However, pages outside of KoL require the full url to be supplied for page.

The version with no parameters is only meaningful in a relay override script; it retrieves the server page that your script is overriding. All four versions behave slightly differently in a relay script; they retrieve a version of the page with any KoLmafia decorations added, rather than the raw page from the server.

In a POST request, if &pwd is part of the page string, it will automatically be replaced by &pwd=###### where ###### is the password hash for the current session. For a GET request the password hash will not be added so you'll want to use my_hash().