Creating Script Method Tables

From Serious Sam Wiki
Jump to: navigation, search

Introduction

This page explains how to create templates for tables that contain all methods of a class.

Creating a Table

General

Wiki Page

Tables with script methods must be created in the Main namespace so that the table can be viewed as such on it's own page. Use the following page name syntax:

[Class_Name_Short]_Methods
[Class_Name_Short]
For ease of calling this should be the class name of the entity you want to build the table for without the 'C'-prefix and without the 'Entity'-suffix.
For instance, the name of the page that contains all methods of CStaticModelEntity should be Template:StaticModel_Methods.
Mandatory Content

Copy the following code into the page and replace the placeholders as specified below:

<noinclude>
This template contains a table with all methods of [Class_Name]. Use the following syntax to include it on another page:
:<code><nowiki>{{:[Class_Name_Short] Methods}}</nowiki></code>

[[Category:Entity Methods]]
</noinclude>
[Class_Name]
Replace with the exact class name of the entity you want to build the table for.
[Class_Name_Short]
See above.

This will serve as documentation for other users that want to transclude the table on another page. It also add the proper category to the page.

Building Blocks of the Table

A table is generated by use of the following three templates:

Header

To start the table use the following syntax:

{{SF_Header|[Class_Name]}}
[Class_Name] (mandatory)
Use the exact class name as it appears in the editor.

Method information

After the header it's time to add method information with the SF_New template. The basic syntax of that template is:

{{SF_New|[param=x]|[P1]|[P2]|[P3]|[P4]|[P5]}}
[param=x] (optional)
Set this parameter to the amount of parameters of the method if this number is higher than one.
[P1] - [P5]
Contain variable information for Method Name, Parameter Name, Parameter Data Type, Return Data Type, Method Description.

End

To conclude the table simply add {{SF_End}}.

Examples

Creating a script function table is dependent on the amount of parameters a specific method has. There are three basic options.

No parameters

If a method demands no parameter, this method is added by using the following syntax:

{{SF_New|[Method_Name]|[Return_Data_Type]|[Method_Description]}}

The code

{{SF_Header|COneMethodNoParamsEntity}}
{{SF_New|Method_Name|Return_Data_Type|Method_Description}}
{{SF_End}}

creates the following table:

COneMethodNoParamsEntity Methods
Name Parameters Return Data Type Description
Name Data Type
Method_Name - Return_Data_Type Method_Description

One parameter

If a method demands one single parameter, this method is added by using the following syntax:

{{SF_New|[Method_Name]|[Parameter_Name]|[Parameter_Data_Type]|[Return_Data_Type]|[Method_Description]}}

The code

{{SF_Header|COneMethodOneParamEntity}}
{{SF_New|Method_Name|Param_Name|Param_Data_Type|Return_Data_Type|Method_Description}}
{{SF_End}}

creates the following table:

COneMethodOneParamEntity Methods
Name Parameters Return Data Type Description
Name Data Type
Method_Name Param_Name Param_Data_Type Return_Data_Type Method_Description

Multiple Parameters

If a method demands multiple parameters, this method is added by using the following syntax:

{{SF_New|[param=x|Method_Name]|[Parameter_Name_1]|[Parameter_Data_Type_1]|[Return_Data_Type]|[Method_Description]}}
{{SF_New|[Parameter_Name_2]|[Parameter_Data_Type_2]}}
{{SF_New|[Parameter_Name_3]|[Parameter_Data_Type_3]}}
[..]
Warning 16x16.png Warning: In case of multiple parameters you need to use SF_New as often as you set param to or else the table will be scrambled!

The code

{{SF_Header|COneMethodThreeParamsEntity}}
{{SF_New|param=3|Method_Name|Param_Name_1|Param_Data_Type_1|Return_Data_Type|Method_Description}}
{{SF_New|Param_Name_2|Param_Data_Type_2}}
{{SF_New|Param_Name_3|Param_Data_Type_3}}
{{SF_End}}

creates the following table:

COneMethodThreeParamsEntity Methods
Name Parameters Return Data Type Description
Name Data Type
Method_Name Param_Name_1 Param_Data_Type_1 Return_Data_Type Method_Description
Param_Name_2 Param_Data_Type_2
Param_Name_3 Param_Data_Type_3

Combination

The above options can be combined as required. The code

{{SF_Header|CMultiMethodMultiParamsEntity}}
{{SF_New|Method_Name_1|Return_Data_Type_1|Method_Description_1}}
{{SF_New|param=3|Method_Name_2|Param_Name_2_1|Param_Data_Type_2_1|Return_Data_Type_2|Method_Description_2}}
{{SF_New|Param_Name_2_2|Param_Data_Type_2_2}}
{{SF_New|Param_Name_2_3|Param_Data_Type_2_3}}
{{SF_New|Method_Name_3|Param_Name_3|Param_Data_Type_3|Return_Data_Type_3|Method_Description_3}}
{{SF_End}}

creates the following table:

CMultiMethodMultiParamsEntity Methods
Name Parameters Return Data Type Description
Name Data Type
Method_Name_1 - Return_Data_Type_1 Method_Description_1
Method_Name_2 Param_Name_2_1 Param_Data_Type_2_1 Return_Data_Type_2 Method_Description_2
Param_Name_2_2 Param_Data_Type_2_2
Param_Name_2_3 Param_Data_Type_2_3
Method_Name_3 Param_Name_3 Param_Data_Type_3 Return_Data_Type_3 Method_Description_3