[Feature Request] Functions List

Discussion and feedback on Construct 2

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

Post » Mon Apr 08, 2013 2:37 am

In the mean time. You can still get around by doing another method to get type safe. Use instance variables

This would be set up in the setting of the object.
Object with name of [foo]
foo.DoDamage = "DoDamage"
foo.TakeDamage= "TakeDamage"



On FunctionCall (foo.DoDamage)
On FunctionCall (foo.TakeDamage)

Condition whatever
--Action > Function.Call (foo.DoDamage)


under this model. You are using variables which are typesafe. these variable store the string for the function calls. So if you do change the variable name or function string name. The changes are global to the event sheets.

B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon Apr 08, 2013 2:49 am

I'm going to have to disagree with most of this.
Whilst I know exactly what it feels like to spend hours debugging only to realise that it's a stupid tiny little mistake that I made, the thing is, it can happen anywhere. For example, realising that an object is behaving strangely but turns out it was on an incorrect layer that had parallax scrolling. Once you have fixed the mistake though, you would probably remember in future to check the layering right away if another glitch were to occur.
I believe the concept I'm trying to get across links with the problem you have, Whiteclaws, with the function being typed incorrectly; since you spent a hellish long time trying to figure out the problem and eventually did, you will most likely look through and verify function names if you realise code is not working correctly from now on.

Anyway, in my humble opinion on the suggestion itself, I'd find a separate "Dropdown list" for functions personally not very useful, and having an error message occur when typing would cripple the Function tool. What if, like Ashley said, you wanted to call a function that had't just been evented yet- you'd get an error and that would be counterproductive. Unless the error message is just a little notification that pops up then fades away, then I can see a little bit of potential in that idea. One problem I once had was I accidently made a new function that already existed and had no idea of telling how until my brain decided to clock on and remind me lol. (That taught me to note down my functions on a commentbox that I have in my capx to prevent future issues). Not to mention how would the Function dialog work if a user typed in variable stuff like ["Load_" & Player.Something]- since there's no definitive "Function" right there unless the game is running, how would the interface know to show an error message or not?
I have no idea why I wrote so much about this but yeah!
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Mon Apr 08, 2013 12:34 pm

@Jase00 , yeah , that's what I'm asking for , a little pop-up message that pops when the function is incorrect and dissapears quickly ... That's not too much isn't it ?
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Mon Apr 08, 2013 3:17 pm

This all seems like an unnecessary workaround to just checking the console tab. As Ashley said, if there is an error in your function name, it will show up there. I have 40+ functions in my tiny project and a massive dropdown isn't going to make things easier to manage.

Now renaming functions and having them automatically update any related function calls, that I could get behind...
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Apr 08, 2013 7:58 pm

[QUOTE=boolean] This all seems like an unnecessary workaround to just checking the console tab. As Ashley said, if there is an error in your function name, it will show up there. I have 40+ functions in my tiny project and a massive dropdown isn't going to make things easier to manage.

Now renaming functions and having them automatically update any related function calls, that I could get behind...[/QUOTE]

Indeed. Like the replacement system.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,192
Reputation: 18,301

Post » Tue Apr 09, 2013 3:11 am

None of the ideas will work well unless it is tracking the Function names anyways. Also with the replace method, then it becomes more type safe.

I agree that you won't be able to use a Function until it's created in the OnFunctionCall, but right now I can't use a variable until it's declared first. So I don't see difference.

I will agree that a dropdown list could get very large. I lost cout of the number of funtions I have :D sooooo maybe a drop down would be less effective :D. Then again if you can have more than one function plugin installed, with each being renamed to a theme of use.

Anyways. I'm backing up the idea that assistance with handling Function naming would be a nice benefit. in the mean time I'm going to work with the object.varfunction = name model :)

I have spoken my piece :) thanks for listening :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Tue Apr 09, 2013 4:35 am

[QUOTE=jayderyu]I agree that you won't be able to use a Function until it's created in the OnFunctionCall, but right now I can't use a variable until it's declared first. So I don't see difference.[/QUOTE]
You stated a very good point, man.
I remember Construct Classic was able to declare variables whilst using the "Set Value" action. I wish this would be brought back.

B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: Ethan and 10 guests