Suggestion for a custom data feature

0 favourites
  • 14 posts
From the Asset Store
DATA+ (Addon Pack)
$18 USD
20% off
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Suggestion for a custom data feature

    Posting the suggestion here because the forum has much better formatting.

    Here is the link to the actual suggestion board please vote for it if you like it.

    https://construct23.ideas.aha.io/ideas/C23-I-266

    Mockup of the feature in action

    Mockup of setting a value in a custom data type

    These mockups show how everything could work, and I mean COULD, I'm not hell-bent on this exact implementation.

    With the custom data feature I try to address a constant annoyance I have with C3, handling of data. Specifically handling of data that is more than just a single float/string/boolean value.

    To explain my 1st mockup, the idea is that you create a Custom Data structure with a unique name as a global identifier. You create a new custom data structure -> you set the name -> add variables -> the variables get a default value. Once you created a custom data structure it shows up as option in (instance)variables with the unique name you choose (lets say it's "my_data_type"). If you set the variable to "my_data_type" it will apply the default values you've set. Double clicking it opens a window pretty much exactly like the window where you add/edit normal instance variables, where you can edit the values of "my_data_type" (but not the actual structure/ which data types are in it with what names or their default value).

    The 2nd mockup shows how to set a value in a custom data type in the event sheet. The content of the custom data type is actually not shown in the expression window because it would clutter it too much, just the name for the instance variable that is holding the custom data. Opening up the instance variable with the custom data is similar to normal instance variables but you get a 2nd drop down to specify which value from the custom data you want.

    Requirements no matter how the final implementation ends up looking like.

    • Storing of more then just a single value in (instance) variables, a collection of data.
    • Being able to handle this data collection like any other variable, it can be easily copied to different variables of the same type ( set "my_data_1" to "my_data_2" ), it can be set as parameter in functions/custom actions ( function( my_custom_data, float, string ) )
    • Ability to create the data structure in the editor
    • Easy access to the data ( variable = player.my_custom_data.value, auto complete can suggest possible variables because the structure of the collection of data is known ( In the mockup the custom data "hero_stats" has hero_type/health/strength/intelligence/immunities ) )

    Things to avoid

    • No double picking ( pick player -> pick dictionary with UID ( player.my_data_UID ) -> do something with data )
    • No conversion of data ( variable = rgb( 255, 255, 255 ) -> variable = random number -> how do I get only red out of this???, OR dictionary -> function( dictionary.AsJSON ) -> pick dictionary -> dictionary load from JSON string )
    • No need to remember names or numbers ( like dictionary keys or array indexes, dictionary.get( ??? What's my key again?), array.get(?,?,? gotta open up the data sheet again and look up the number ))
    • No AJAX to load data

    One thing that would be amazing is nested custom data, but idk how much more difficult this makes the implementation, so I rather have the feature without it than not having it at all. I did however include nested custom data in the mockup to show how that would look like.

    One last thing worth mentioning is that there would be another way of achieving all this, if it was possible to save instances themselves in variables. I imagine that would be much more difficult to implement, but maybe I'm wrong, idk. If we could stuff Sprites into variables and be able to access their bits like "player.sprite_instance.instance_variable" then that would be even better. But I imagine that's harder, would we also be able to access behaviors on it then like "player.sprite_instance.8Direction.MaxSpeed" or things like "player.sprite_instance.AnimationFrame"?!

    Okay if you read all that you must be interested, so please go over here and vote for the suggestion.

    Vote here!

    And leave a comment with your feedback below, thanks.

  • R0J0hound made a good suggestion

    ...to be really useful it should be possible to change all the values at once easily. ...Like in many programming languages you can set a vector struct with something like velocity=vec(100,100).

    So here is a mockup of how that would look.

    Here you can see that it gives hints for the expected data, just like functions.

    And this is how it would look with the complete data filled in. Again including the nested custom data. First one is with the custom data written in directly, second one is with custom data already stored in another variable.

    Here are a few ideas how a global variable containing custom data could look like on the event sheet.

  • I believe what you are suggesting is very close to JSON. Of course, dealing with JSON is not as easy in C3 as working with variables, but it can provide all the functionality and flexibility you described.

  • ...dealing with JSON is not as easy in C3 as working with variables

    So you mean it doesn't bother you?

    Because I don't see how the JSON workflow is any better than the workflow with Dictionaries for example. Basically all the points I made under "Things to avoid" also apply to JSON, or not? And only half of what I mention under "Requirements" is actually possible with JSON.

  • i think there is a plugin called herostats that does all this

  • i think there is a plugin called herostats that does all this

    I don't know of such a plugin, can you provide a link please GeorgeZaharia

  • So you mean it doesn't bother you?

    I guess I got used to it, but it doesn't. There are about 30 different JSON objects in my project, storing all kinds of data from single keys to huge structures of nested arrays with tens of thousand values. Maybe I don't understand all points of your idea, but I can't imagine a custom feature based on variables having that level of flexibility.

  • I'm not suggesting this should replace JSON/Dictionary/Array, so you will still be able to use it.

    In other engines you can store all kinds of stuff in variables, it is not some crazy outlandish idea. Construct is actually very odd in that regard that you can't even store arrays in variables.

    Also at this point I'm expected to know more different coding paradigms in this "No coding required" engine with "Game Changing Visual Scripting" than I need for an actual coding required engines.

    UI = Html + CSS

    Data = XML or JSON

    And more and more often = Javascript

  • Currently construct uses numbers and strings as values in expressions. Any other type: Boolean, dictionaries, arrays, etc.. are manipulated via actions and expressions. For example the Boolean expressions effectively converts to numbers. Anyways, it’s not alone in doing this, clickteam products do or did this (haven’t used them in a while).

    The closest we got to another value type was immutable arrays in construct classic. You could specify an array like {1,2,3} then store it in variables, or index them with someNumber. You couldn’t change them after they were defined though. It was prone to crashing but was interesting.

    It would be nice to have arrays and dictionaries as variable types too. Mainly to avoid having to deal with picking and to possibly make things look cleaner.

    What’s being suggested here are structs, which would be a nice way to group values. Currently we can kind of do that with sprites with instance variables, or a dictionary with a fixed set of keys. The sprite is better than the dictionary method because the expression editor will catch typos at edit time. Both aren’t ideal because they have to be picked. Picking is fine with simple cases but often we end up having to do juggling with how things are picked to access and modify things.

    The json object is an improvement since you can have as many arrays and dictionaries in it as you like. You still have to pick it, but that’s usually fine since you can get away with a single instance. The main downfall of it is if you make typos in the json paths you won’t know until running it. But I guess that’s the nature of dynamic data structures, you have to check at runtime.

    Structs are nice because you define it at edit time and the editor can catch a typos you make before the game runs. You wouldn’t have to worry about something silently returning 0, or having to check the browser console for errors.

    Anyways just some thoughts.

  • Are you aware that you can put data storage plugins like Array, Dictionary and JSON in to a container and get per-instance storage? That feature is aimed at covering exactly this, for more advanced per-instance data storage.

  • Yep. Use that all the time. It only doesn’t work when dealing with values between instances of the same type, but I guess that’s a general event problem.

  • Containers do not work with families, and you need families if you want to make things generic in C3.

    If you work with containers you need to add a new dictionary for every single object which you then can't universally address because you need to perform actions on that particular instance of the dictionary.

    Group #1 shows how it does work, here if you click Sprite_A, dict_A loses health, but not dict_B.

    Group #2 shows how it should work but doesn't. If I click Sprite_A here, dict_A AND dict_B lose health.

    Here is the project file: container_data_test.c3p

    But this is just an example I threw together, and it's not about solving just this very specific case. Having the ability to store bigger data in variables would make dealing with it as easy as dealing with strings or numbers. I often lose track of what I was working on because I get distracted by needing to solve mini puzzles on how to deal with data.

    Maybe not everyone likes my solution to the problem, however basically everyone expressed that they do find dealing with data difficult. That was my motivation behind this suggestion, and starting a discussion.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yea containers are not really usable aside from some very limited cases imo, I would greatly appreciate a rework of containers to work properly with families, hierarchies and templates.

    I originally had this included in my suggestion "hierarchies for all object types" that you closed (thank you for adding support for a bunch of objects tho), saying that you only want hierarchies to be used for moving objects. But than we need another way to add them that allows the same amount of flexibility, which containers don't in their current form.

  • Have you added this to the gihub suggestions? I didn't see it over there but wanted to double check.

    Data is a major reason why sometimes I choose unity over construct. Though usually it's due to lack of abstraction.

    Solving the nested families issue, or allowing cross family picking would also improve working with data without even specifically addressing data issues.

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