Idea discussion: List, enums & more for built-in Functions

1 favourites
From the Asset Store
Template for scrollable list, fully documented in comment and video
  • Hi there,

    Due to a recent idea I did submit over here I decided to make this topic in order to discuss it, because maybe you guys might want to add more to it, maybe more types, more elements to these built-in functions, but if you think the base idea would be a great addition, feel free to tell it here or upvote the idea

    Right now, the idea that I did submit was mainly for Lists, which could be used this way

    Let me know if you'll find it useful as well, could help a lot for the workflow, especially more if those lists could be linked somehow to an enum type, would be even better.

  • yes, this would be great!

  • Are you talking about Function parameters?

    Do you mean predefined lists with fixed values (for example, color names, blend modes etc.)? Or custom lists, where you enter values yourself (for example enemy types)?

    I can see how custom lists may be useful in some cases. Say, when you are calling "SpawnEnemy" function, instead of typing "zombie" in function parameter, you can select "zombie" from the drop-down list. However, there is a serious problem - you will lose the ability to enter expressions in this field, for example choose("zombie", "vampire").

  • Are you talking about Function parameters?

    Do you mean predefined lists with fixed values (for example, color names, blend modes etc.)? Or custom lists, where you enter values yourself (for example enemy types)?

    I can see how custom lists may be useful in some cases. Say, when you are calling "SpawnEnemy" function, instead of typing "zombie" in function parameter, you can select "zombie" from the drop-down list. However, there is a serious problem - you will lose the ability to enter expressions in this field, for example choose("zombie", "vampire").

    It seems pretty clear with the image above but yes, we're talking about a parameter type for built-in functions.

    I don't understand your example to be fair, like, if you want to have a text field, you just select the string type and you'll have it, this already exist.

    What we're talking here is, like in the image above, a list/switch/enum type of definied choices you can set, in order to have a better workflow working with it, like in the image (for selecting the ease function in this case)

    And I think you got it wrong saying 'you can enter in a textfield' because this isn't about that.

    This system will help a lot if somehow you have to refactor a lot of functions, as in the call of the function, you'll have selected a specific id from that list, you can then rename them, reorganize them, without having to go back 1 by 1 on each function call and rename your call properly. (Kinda like when we had the old functions and params that were a mess, it was just awful to go back on all your calls to change everything, and this has been solved now)

    This system will also be useful if somehow, these lists could be linked to an enum type file, which then can be imported in that list from this function. This would definitely be helpful

  • It seems pretty clear with the image above

    Your image shows dialog window for Tween behavior, it has nothing to do with functions, that's why I found it confusing.

    Besides easing modes, what other lists do you want to have in function parameters, can you please give a few examples?

  • Besides easing modes, what other lists do you want to have in function parameters, can you please give a few examples?

    What? I'm sorry but you clearly didn't read what I've been writing because this has literally nothing to do with the proposal.

    The image I linked about tweening is an example of how that'll look like integrated in the built-in functions, because the dialog you can see right there is literally the same one that we use when making a function call.

    What we're talking here is, like in the image above, a list/switch/enum type of definied choices you can set, in order to have a better workflow working with it, like in the image (for selecting the ease function in this case)

    This system will help a lot if somehow you have to refactor a lot of functions

    This system will also be useful if somehow, these lists could be linked to an enum type file, which then can be imported in that list from this function.

    I mean, it's all crystal clear to me, I'm not sure what you're not getting from it

    We're talking about a new parameter type, not integrating easing modes to functions???

  • There's a lot of stuff that needs fixing before we start talking about extra stuff like enums.

    For example some objects require inputs as strings rather than numbers, and some that don't care what you put into them just so long as it's either a number, or has quotes.

    Some objects will reject the wrong type, and some will accept it, but not work as expected.

    Then functions can get ridiculous if you aren't careful and document every little thing.

    Don't even get me started on the color settings...

  • We're talking about a new parameter type, not integrating easing modes to functions???

    I'm not talking about it either. But since you used it as an example, you can have a function which is a wrapper for Tween behavior. It will expect easing mode as a parameter, and this parameter can be enum/list type.

  • > We're talking about a new parameter type, not integrating easing modes to functions???

    I'm not talking about it either. But since you used it as an example, you can have a function which is a wrapper for Tween behavior. It will expect easing mode as a parameter, and this parameter can be enum/list type.

    Oh then my bad. I mean like, there could be a million situations where this might be useful for someone. Tweens can be one of them, but this could be used in literally any situation possible. I don't count how much time I used List in C#, it just feels wrong that we still don't have this option on Construct, you just have to check how much addons use these lists (like the tween addon) or features, to realise how useful that'd be

  • Ok, so lets say you have a function "RunMyTween" with enum parameter easing_function. When you call this function, in the dialog you can select the value for easing_function parameter from the list, like this, right?

    But my question still remains - if you need to use an expression instead of selecting the fixed item from the list, how do you do it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, so lets say you have a function "RunMyTween" with enum parameter easing_function. When you call this function, in the dialog you can select the value for easing_function parameter from the list, like this, right?

    But my question still remains - if you need to use an expression instead of selecting the fixed item from the list, how do you do it?

    Yes, this is the example I used, but if you need an expression, I'm not sure why you're even asking this, as you mentioned you have the string var type.

  • You are proposing enum type for functions because it will make them more organized, easier to use and refactor, and I agree with you. But there must be an option to use expressions with enum parameters. Are you saying that if I want to call my function with parameter choose(Linear,InElastic,InSinusoidal), I will not be able to do it, and will have to use string type parameter instead? This is a serious disadvantage and limitation.

  • You are proposing enum type for functions because it will make them more organized, easier to use and refactor, and I agree with you. But there must be an option to use expressions with enum parameters. Are you saying that if I want to call my function with parameter choose(Linear,InElastic,InSinusoidal), I will not be able to do it, and will have to use string type parameter instead? This is a serious disadvantage and limitation.

    If you have a return type, what's stopping us from accessing the list directly from Function.EaseType.choice1 ?

    I mean, this isn't a disadvantage at all, why in the world would you want a custom input on something that is an enum? This makes no sense, enums are static, that's how it works.

    If you want a custom input, you just use a regular string like you would normaly, I don't see what's disturbing you here.

  • why in the world would you want a custom input on something that is an enum?

    It's not a custom input, it's a common use case.

    If you have a function "SpawnEnemy" with enum parameter enemy_type (list values: zombie, vampire, troll), how do you spawn a random enemy?

    Or let's say there is a function "SetHealthbarColor" with enum parameter color (red, green, blue etc.) You want to call this function and set color to (Player.health<20 ? red : Player.health<50 ? yellow : green).

    If expressions are not supported for enum parameters, then you'll have to do this:

    If Player.health<20 then Call "SetHealthbarColor", color:red
    Else If Player.health<50 then Call "SetHealthbarColor", color:yellow
    Else Call "SetHealthbarColor", color:green
    

    Three lines of code instead of one!

  • while i think ENUM data types would be a great addition to construct, they need to be added holistically to the engine not just as function params,

    i agree with dop2000 not being able to use an expression in this case would really limit you, but with that said there might be a middle ground?

    enums are really just integers, lets say you were able to define them like you do a variable (global) you could have a new data type for function param called enum (which will really just take any enum type or expression) so instead of typing out a string you could do MyEnum.Choice, and the actual value of this would be the the assigned integer of Choice in the enum. this should still give you scoped intellisense but also allow for expressions based on the enum, and they could be useful outside of function params as well.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)