Adding Expressions [Documentation]

For developers using the Construct 2 Javascript SDK

Post » Sun Mar 11, 2012 5:50 pm

I believe that the documentation for the AddExpression function within the SDK documentation here may be intended to be described as

AddExpression(id, flags, list_name, category, expression_name, description);

instead of

AddExpression(id, flags, list_name, category, expression_name, script_name);
Jayzon2012-03-11 17:51:28
B
4
Posts: 3
Reputation: 581

Post » Mon Mar 12, 2012 3:54 pm

No, the existing documentation appears to be correct. script_name is the name of the corresponding runtime script function. Is there something ambiguous in the documentation here which could be improved?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Mar 12, 2012 5:22 pm

Hi Ashley, the SDK template that I had downloaded from here describes the last parameter of the AddExpression function to be as a description parameter. It also shows that the script_name parameter is used for Actions and Conditions, but not for Expressions.

the example given within edittime.js is shown below.

AddExpression(0, ef_return_number, "Leet expression", "My category", "MyExpression", "Return the number 1337.");

Clearly, the "Return the number 1337." string is not a script name. Has there been a change to the AddExpression function that I am just not aware of and the template needs to be updated? I doubt that is the case because my plugin seems to be working correct with the Expressions that I have been working with.Jayzon2012-03-12 17:23:35
B
4
Posts: 3
Reputation: 581

Post » Tue Mar 13, 2012 3:50 pm

It's actually correct, the expression name (exp_name) is used as the script name for expressions.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Mar 13, 2012 6:00 pm

Ashley, sorry but it seems to be getting more confusing. My intentions is to simply point out that the SDK Template and the SDK documentation describes the parameters used for the AddExpression function differently. I am surprised to hear that this could be correct.

I will try once again to point this out because I believe that the difference between the SDK Template and SDK Manual(as it stands) may cause confusion for newcomers to the community (it certainly did for me).

The difference is shown below.

[SDK Template]
AddExpression(id, flags, list_name, category, exp_name, description);

[SDK Manual]
AddExpression(id, flags, list_name, category, expression_name, script_name);

The SDK template and the SDK Manual both explain that the exp_name is used as the script name for expression (as you previously stated).

However, if the exp_name is used for the script name, then why is there a separate "script_name" parameter in the SDK Manual for the AddExpression function? Also, the listed "script_name" parameter in the SDK Manual for the AddExpression function is not documented at all on its use.

I believe that the SDK Template describes the parameters correctly because treating the last parameter as a string for displaying a description within the expressions panel during my plugin testing appears to work (meaning that the description that I add shows up in the expressions panel).
B
4
Posts: 3
Reputation: 581

Post » Wed Mar 14, 2012 5:26 pm

Aaahhh, I see, sorry for being slow! You're right, the documentation in the manual was wrong and the template was right. I've updated the manual to mirror what the template says. Thanks for spotting this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests