Scirra / Construct-feature-requests

A place to submit feature requests and suggestions for Construct.
https://www.construct.net
11 stars 1 forks source link

Conditions and variables in Flowcharts #204

Closed NedSanders closed 6 months ago

NedSanders commented 7 months ago

Reviewed guidelines

Checked for duplicate suggestions

Summary

I would like to request the option to read and write variables directly from nodes. This is something that a lot of dialogue tools such as Chatmapper, Articy Draft, etc. have already implemented, so there are a lot of great frames-of-reference for best practices and implementation.

Currently, it is possible to use tags and other workarounds to execute code from flowchart nodes, but the solutions are very hacky and unintuitive, outlining the limitations of Flowcharts in their current state.

Possible workarounds or alternatives

I believe is theoretically possible to achieve similar behaviours already. The closest I've found is by using "evaluate expression" to read variables. However, this quickly becomes very clunky and requires you to create a lot of custom code. It also takes up use of the tag functionality, making tags hard to use for anything else and creating instabilities from large amounts of hacky code and complex token logic.

Proposed solution

I think this could be achieved with two additions:

Reading: The option to 'Add Condition' to a node. A basic version of this would be a basic expression ("HasGem=true", "Coins<=15", "Friendly!=true, etc.). In this case, multiple conditions could be handled with the inbuilt expressions like "& or |". If we wanted this to be more user-friendly, UI could exist to add these conditions as separate elements, similar to the compare variable function already in the code, but I appreciate that that could be more complex. Similarly to other branching flowchart tools, this would allow the node to be skipped over if the conditions are not met.

(NOTE: It would also be great if this could be applied to Options, allowing certain choices to be removed if their individual conditions aren't met)

Writing: The option to alter variables directly from nodes. You could either set a variable or add to/subtract from it. Compared to the above, this is a bit simpler to achieve already. But I still feel that it would complement the Reading feature and allow users to see all variables and conditions in one place, more in line with what people expect from industry standards.

Why is this idea important?

In my opinion, the Flowchart feature is one of the most exciting things that's been added to C3, opening users up to more narrative-heavy projects and complex behaviours that can still be visualised in a clearer and simpler way. Whilst it's still in its infancy, I think it could grow to rival complex narrative tools with only a few minor additions - this being one of the key ones.

Users could not only use the feature to create complex branching dialogues that can fit into a wider narrative with very little hassle, but also complex behaviours and AI that react to the game state dynamically. It would expand the accessibility of C3 and the types of games that can be created with it to rival that of its competitors.

Additional remarks

No response

NedSanders commented 7 months ago

Upon investigating further, it seems that Construct lacks an "eval()" type function, meaning that conditions are in fact not something that can be easily achieved already, making this an even more necessary feature.

DiegoScirra commented 6 months ago

We have no plans to add logic directly to flowcharts. Unlike other tools that use some kind of node system to define logic, C3 already has a far superior method to do that in the form of event sheets.

Adding logic capabilities to flowcharts would effectively be re-inventing a wheel, because of that, in C3 flowcharts will remain purely as a data structure to be processed by event sheets.