[PLUGIN] rex_Function2

Post your completed addons to share with the community

Post » Sat Nov 12, 2011 11:44 am

rex_function2
passing name-value to function



----
Function (Update 2012/05/11)

Function plugin provides to define function(event). It's important for my plugin system.


Function plugin now provides three ways to call a function. Example

1. tradition way, like in C1

Code: Select all
Action: Set parameter
Action: Call
Expression: Get result



2. expression:Call

Code: Select all
Expression: Call

The 1st parameter of "expression:Call" is function name. 2nd, 3rd parameters are mapping into param[0], param[1]


3. action:execute commands

Code: Select all
Action: Execute commands
Expression: Get result

The parameter of "action: Execute commands" is a string. It's similar to "expression:Call". 1st parameter is a function name, 2nd,3rd parameters are mapping to param[0], param[1].

There are two different between "action:execute commands" and "expression:Call".
1. parameters(not function name) will use "eval" to get number or string. If you want pass a string parameter, use single quotation marks, ex 'hi'.
2. two or more commands can concatenate by "\n"(newline) in a single string.

More usages will be introduced next time.


In Function plugin, expression:param is use to pass input parameters. There are two way to pass return value(s).
1. "Expression:Result" is use to return single value to "expression:Call"
2. "Expression:Ret" is use to pass more then one return values.



Advance:
Action: Inject JS function objects
Debug mode propertyrexrainbow2013-02-12 16:51:04
Last edited by rexrainbow on Thu Mar 27, 2014 9:31 am, edited 1 time in total.
B
60
S
13
G
11
Posts: 1,904
Reputation: 14,045

Post » Sat Nov 12, 2011 11:46 am

amazing..ty a lot
B
114
S
19
G
11
Posts: 185
Reputation: 13,494

Post » Mon Nov 14, 2011 10:50 am

I had updated some code. Please download it again.
B
60
S
13
G
11
Posts: 1,904
Reputation: 14,045

Post » Mon Nov 14, 2011 10:26 pm

ty,already grabbed from your gitHub ^^
B
114
S
19
G
11
Posts: 185
Reputation: 13,494

Post » Wed Nov 16, 2011 4:07 am

Update:

Fix bug in "Action:Execute commands". Now, you can pass command string with null string parameter like "fn,".

("Action:Execute commands" is usually used by WorkSheet plugin)


Thank gonzdevour to find this bug.rexrainbow2011-11-17 01:17:31
B
60
S
13
G
11
Posts: 1,904
Reputation: 14,045

Post » Wed Nov 16, 2011 11:01 pm

Say that you wanted to pulled the value from a variable like this...

Variable1 = 123

...but with two variables holding "Variable" and a 1

How would you accquire that "123" with the function code?

Thank you for making this plug-in!

-D
B
4
G
1
Posts: 6
Reputation: 513

Post » Thu Nov 17, 2011 1:33 am

Only method1 (traditional) can pass variable name = "Variable1", and value = 123. You can use "Action: Set parameter"
[code]Set parameter ["Variable1"] to 123[/code]


Sorry, I am not really understanding your question. Do I hit the target?rexrainbow2011-11-17 01:35:01
B
60
S
13
G
11
Posts: 1,904
Reputation: 14,045

Post » Thu Nov 17, 2011 7:34 pm

Kind of, and thank you for helping me!

I mean I'm used to coding something like this in Actionscript...

Variable1 = 123;
vara = 1;

grabbedvar = eval("Variable" + 1);

To obtain the value "grabbed" similar to this with your plugin, how could I accomplish that?

-Dan
B
4
G
1
Posts: 6
Reputation: 513

Post » Thu Nov 17, 2011 8:11 pm

@djbav : Even though C2 exports project as javascript in the end, the coding itself in C2 is different and relies on its own rules.
You should really check out/again the Beginners guide to C2, get used to expressions and check out the system expressions list.

You can directly use the name of your variable as expression.

If you want to get the value "123" out of "Variable1" and set it to "Variable2" for example:
Make a condition system set value global variable, pick "Variable2" and set value to "Variable1".

Variable2 will now contain Variable1's value.

This is covered and demonstrated in the beginner tutorial, and you can read more about variables in the How do I FAQ.

This article from Scirra's blog should be worth reading too.Kyatric2011-11-17 20:15:01
Moderator
B
154
S
53
G
28
Posts: 5,413
Reputation: 41,354

Post » Thu Nov 17, 2011 8:14 pm

It certainly does, thank you :)
B
4
G
1
Posts: 6
Reputation: 513

Next

Return to Completed Addons

Who is online

Users browsing this forum: drops and 1 guest