[Feature Request] Functions List

Discussion and feedback on Construct 2

Post » Sun Apr 07, 2013 2:09 pm

@vee41

I'm talking about the event sheet ... displays an error when you don't write the correct function ...
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Sun Apr 07, 2013 3:17 pm

I see value in having a drop list of all the functions
that you created, better then having to remember them but I would say low on feature list I also bet its probably simple for Ashley to add.
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Sun Apr 07, 2013 3:56 pm

Construct 2 already logs the following message to the console if you call a function that doesn't exist:

"[Construct 2] Function object: called function 'blah', but no event was triggered. Is the function call spelt incorrectly or no longer used?"

If you're not already keeping an eye on the browser console while developing, then you should.

Dropdowns can make the workflow a little clunky sometimes; if you want to add a 'Call function' action then afterwards make the 'On function' event, if there's a dropdown which only shows existing functions, you can't add the 'Call function' action first.Ashley2013-04-07 15:56:58
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Apr 07, 2013 4:40 pm

@Ashley , could we get that incorporated in the editor ?
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Sun Apr 07, 2013 6:06 pm

Get what incorporated to the editor?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Apr 07, 2013 6:21 pm

@Ashley I believe they are asking for a dropdown that lists all the functions that have been created in the project, similar to the other thread about having dropdown lists or combo boxes for animations, etc... basically anything that we have to type currently that we may have already defined by assigning a name to it (functions, animations, etc...) Either dropdown boxes or where it makes sense combo boxes for those that need to allow manual input still.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Mon Apr 08, 2013 12:17 am

I have to agree with WhiteClaws in regards to the volatility of Functions. In relation when a variable is created; C2 makes it impossible to type in the var expression wrong.

eg
variable number called count
in a typed expression: cout becomes wrong and the expression will fail as C2 checks to see if a variable cout exists. So C2 informs us when cout is invalid and won't close the window until corrected.

eg
variable text CONST GLOBAL GAMEMODE
On Event > Compare variable... I have a drop down menu of variables


So WhiteClaws and I would like the same type safe feature that variables get, but for On Function calls.


Action> Call Function > Dropdown list of any Function that is registered with OnFunction() Event

Typed Expression: Function.Call("[function foo]")
where foo becomes typed safe similar to a variable(unless of course stored in a Text)


OnFunction: change other references
Similar to variables, when the OnFunction Event function name is changed. C2 can proceed to correct any other references to the function call string.


The only exception to the this typesafe function system would be this kind of situation
Object.TextFoo = FunctionName

exception
Function.Call(Object.TextFoo)

this is the only case where C2 type safe would not apply. As the Function stored as a String is not accessible for type safe.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon Apr 08, 2013 12:46 am

Or even a little message that would get incorporated when the text that got written is not registered as a call ... ( Excluding stuff that got written without the "" )
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Apr 08, 2013 1:45 am

The way it is now is no different than comparing a string under system compare. Imagine having made the mistake of testing some text with capitols in it. That kind of mistake happens all the time.
I can bet you'll not make the same error soon however.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Mon Apr 08, 2013 2:22 am

[QUOTE=newt] The way it is now is no different than comparing a string under system compare. Imagine having made the mistake of testing some text with capitols in it. That kind of mistake happens all the time.
I can bet you'll not make the same error soon however.[/QUOTE]

Within C2, which is what we are talking about. Not actually text based code editing. C2 has numerous typesafe guards to reduce syntax errors. Which is the great strength of VPL based tools.

In your example your making a comparison of
"string" == "string"

But that's not the case in C2. When comparing variables as a condition. The variable is drop down. Even if the variable is a string.
Event Compare [Variable] = "string"

In this case, 1 side the comparing variable side is typesafe. There is no way to make an error using the wrong variable. C2 never let's the developer use the wrong variable.

Not only that. in C2 if you do
Event Compare 2 values
var1 = var2
or
Action > set var [ var1 > var2 ? var1 : var2 ]
both vars must be spelled correctly for C2 to validate. Even in the typed expresion of embedding a logic code C2 requires that the name of the variables be valid before the action box can be closed.


We know that syntactically that Function calls are just straight string compares, but thats the same for variables. So why not typesafe Function strings.


Programming requires 3 primary components
variables
code flow(if, else, while, for, case...)
routines(Functions, Methods, GoSub)

Variables and Codeflow are type safe in C2. So why not typesafe the Functions?



to achieve the goal of typesafing Functions. The Function Plugin would require a shared list. The list would be composed from the Event OnFunction. That way C2 can check string for validity when the expression Function.Call("check this string") is used in an action.

It's totally doable and within C2 syntax safety makes a lot of sense :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests