Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_function2

Plugin, ACE table, Discussion thread
Dependence: None

Introduction
This plugin was extended from official function plugin. It could call function with a parameter-table which is a name(string)-value hash table, and it was compatible with official plugin - call function with a list of parameters.
So it has two ways to pass parameters - using a parameter list, or a parameter table.

Usage
Sample capx
图片
Function interface and function body
Put "Action:Declare parameter" before use "Expression:Param", user could assign a default value and a type checking if this parameter could not be found at input parameter table, then it could be got by Param(name_string).
The sequence of "Action:Declare parameter" will map to the parameter list, so that user could get value by Function.Param(name_string) or Function.Param(index_number). In the above case, Param("n") will the same as Param(0).
User could hide function body by collapsed sub-events, only show the function interface (function name and parameter declare), it might be more readable.

Call function
Use "Action:Call function" under "Parameter table" category to call function with a parameter table, which defined by "Action:Set parameter". User could pass different table to different function call to prevent confuse. "Expression:CallwPT" is similar with "Expression:Call", user could call function with
CallwPT(function_name, param_name0, value0. param_name1, value1 ...)
It also could pass parameter list by "Action:Call function" under "Parameter list" category, pick parameter with Function.Param(index_number) like official function plugin.

Type of parameter
Sample capx
"Condition:Type of parameter" could get the type of parameter (number or string). It could be used for some special cases.

Return a dictionary or a JSON
Sample capx
Call "Action:Set return value" under "Return: dictionary" category to set a key in return value. i.e return a dictionary. Key with "." will be splitted into keys to create a JSON object of return value.
Get return value back by "Expression:ReturnValue", there are 3 kinds of output-
  • Expression:ReturnValue : return a JSON string of all keys
  • Expression:ReturnValue ( key ) : return the value of a key
  • Expression:ReturnValue ( key, default_value ) : return the value of a key, or default_value if key doesn't exist.

Debug
Set "Debug mode" to "On" in properties table could dump the trace of function call at console, include passing parameters. Or insert "Action:Dump" to dump all parameters at console.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About