Functions Feature Needed

Discussion and feedback on Construct 2

Post » Thu Sep 11, 2014 10:43 am

You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
Posts: 1,429
Reputation: 12,753

Post » Thu Sep 11, 2014 10:51 am

I will +1 for the ability to have the function name remembered.
I will however -1 for the ability to have functions as a primitive, it adds nothing more than what we have and would need adjustements to not break things, and also this would be a breaking change unless the function object is still here, but then we would have both solutions for the same result.

Also having a basic template with all type of inputs, function object, and dictionnary and array would be nice to have, but not mandatory.
Game design is all about decomposing the core of your game so it becomes simple instructions.
Posts: 2,123
Reputation: 17,200

Post » Thu Sep 11, 2014 2:22 pm

sorry. I should have been clear codah.

From an Event Action line yo are right.

System.Call(system.function, a, b, c )
Similar to variables listed in the system listbox if you do a lot of object clicking style programming. This style is already kinda supported by the current design, but puts the root C2 rather than use of a plugin.

Sprite.setX : functionName(a, b, c)
What I was thinking was for expression line where you embed function calls usually for the immidate return type in an expression. ie Sprite.AnimtionFrame = Function(blah). In this case the function being primititive and similar to vars.

I tend to use Functions a lot with expressions.
Posts: 2,457
Reputation: 15,177

Post » Thu Sep 11, 2014 3:30 pm

+1, I've been using the constant variable workaround but it's still a pain. I'll try OPs method.
Posts: 197
Reputation: 3,415

Post » Thu Sep 11, 2014 7:40 pm

@TwinTails - My method is pretty much the same as using global constants - I just put them in an object because I NEVER use global variables; mostly because you can't sub group globals while you can use objects to sub group variable names... without subgrouping variables I can end up with hundreds of globals... and their names have to be stupid long to keep them organized (i.e... Character_FinalBoss_AtackStrength_01) this in turn makes some of the events harder to read...

In the end I create an object PlayerFunctions or BossFunctions... I then tend to name all variables according to certain conventions that allow me to keep them organized yet still easily accessible in that huge drop down list* ... and since I can sub group objects, finding what I want quickly becomes easier.

player_fm.caculateAtackVector (m = shortcut for math, f shortcut for function)
then that variable would be set to something like: "Player_Functions_Math_CalculateAtackVector" ... A real pain to spell out every time you want to call it... The beauty of it is that you never even need initialize any of these data storage objects as you normally just need their variables as constants.

While I am thinking about that dropdown list.... I think it is stupid*. It works when you have like 4 variables but not when you have dozens, if not hundreds... You can't even type in the name of the variable... you have to select from the list... but in other cases you can actually type it in. For example:

If I set a variable to some value, I have to select the variable from a giant drop down list. Only the first keystroke works to find it, but as I use v_before most variables this does me no good.

The reason I use v_before most variables is because If I do the following:

Player.physics.velocityX = V_somevariable .... and I haven't organized my variables its hard to find the variable in a list of all the sprites expressions and so on... Again, the default conventions are nice, but not in large projects. The bigger the project the more tedious some things become.

I would love a data object that simply stores variables, instead of having to use a sprite...
Posts: 566
Reputation: 5,282

Post » Thu Sep 11, 2014 9:33 pm

@Twintails yea it's more object-oriented to have an object that stores the constants, and easier to organise I agree. Might give it a go, but to date I haven't had dozens of functions to deal with. And I've also noticed that underscores mess up C2's incremental name searches.
Posts: 1,646
Reputation: 6,596

Post » Thu Sep 25, 2014 1:08 pm

I think part of the difficulty is you would still need a text file that contained the name of each function.


Then the system could pull/check the list with text prediction. It wouldn't be much unlike how your doing it now. You would have to maintain the list of function names yourself and then have functions to check against that list.

What would be cool is if when you create a uniquely named function, the system automatically added it to an internal custom list for later access. Then it's baked in. I'm not sure of the performance demand on this though.

There might be a way to build a plugin for this, but I've never played around with the SDK. Any update on if anyone is working on something like this or maybe the devs?
"In truth we live, In Truth we die"
Posts: 22
Reputation: 3,177


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests