—
TLDR: you said use scripting. I agree, but then the benifits of the event system and constructʻs core strengths (speed and ease) start to diminish.
With the examples in the original post, I think it would make more sense to provide your solution in other engines/languages and the problem you forsee implementing in Construct since your claim is that Construct causes difficulties.
In a component based engine where classes are components, example of one class:
//Add to any object that needs inventory
//Overide to add specific functionality
Class HasInventory {
List<Items> inventory = new List<Items>();
public void AddItem (Item item) {
Items.Add(item);
item.OnPickup(this)
}
public void DroppItem (Item item) {
//check if item can be dropped and is in inventory
...
item.Ondrop( this );
Items.Remove(item);
}
}
Class ExampleItemHealthSucker : Item {
private HasHealth heldBy
Public void OnPickup(HasInventory temp) {
heldBy = temp.getcomponent<hasHealth>();
Public Update() {
//do a thing to the holder
if (heldBy!=null)
heldby.modifyHealth(-1);
Public void OnDrop(HasInventory temp) { destroy(this.gameobject) }
}
Take the above code, slap an inventory component on any object that needs it, and add item to any object that can be collected. You need alot more to make this water tight and dummy proof, but that isnʻt the point.
Any additional behavior and you can inherit from either class. Maybe a thief picking up a wallet always removes the money from it and adds it to his own pocket. Maybe the vampire medalian only remove health from its owner if a silver cross is also in the inventory. Maybe the bomb explodes and kills the owner and all inventory both up and down the chain. Maybe many things, but all things can be handled by a script attached to the object handling it.
I do agree that sometimes I find myself wishing I could quickly use a .map() to achieve something - and yes, you can use JavaScript in Construct. As others have said, it is preference.
I agree, this is something javascript should be used for. But... then the strength of construct, no longer applies. If I am authoring plugins/behaviors and scripting... VS/C# and unity wins almost everytime. Simply on grounds of performance, scale, ability to keep projects SOLID, etc...
Construct has some major +++s but right now, the scripting environment isnʻt as good as other tools.
But with events, I don't see why you couldn't achieve either of those with mostly instance variables and functions.
Because the number of effects, items, types, etc... isnʻt known. if you know a character will only have two stats, you can hard code it. Easy, happy to do that in construct- If you know there is only water and fire effects, you can hard code it. But creating a system to handle nTypes, nEffects, etc... Not so easy. You need arrays or dictionaires for tabbing UIDs of objects, you have to iterate through those objects. Callbacks in the form of strings used to invoke functions are needed - and probably some scripting so you can avoid the silly function maps.
I prob would recommend JavaScript.
Me too, but then, what advantage does c3 then have over unity? or monogame for that matter?
My point is that these are the same tools you would use to achieve your functionality in any programming language. It does seem a bit awkward at times, but that is because Construct was originally built as a no-code engine. So there are some trade-offs there - think target audience. However, I'm a programmer and still enjoy using Construct. I'm not actually sure why, but I do!
Agreed. All points. I keep coming back to construct over and over again.
> but with constructs current limitations . . . to avoid c3 limitations in functions and custom actions.
What are the limitations? Can you elaborate?
Encapsulation, private properties, custom actions canʻt return a value, functions are always in the global space, all objects are in the global space, you canʻt attach functionality to objects through events (you can make behaviors though).... Like you said, construct is swift in the right circumstances... but at scale, it can be unweildy if you donʻt build your own pluggins and behaviors
Also, I'm not sure who said it, but I don't think it is fair to say a lot of loops or for eachs would kill performance. Of course a certain amount of loops will kill performance - anywhere, any engine, platform - but I've seen people act like adding a couple of "for loops" into their project is the end of the world. I'm just saying, test it to see if it actually does, especially if you are making a video comparing engines, ha.
Foreach and function call events have performance overheads that are significant depending on the gameʻs scope. The more you do in a funciton, the less the overhead matters, but if you have routing functions only to do a single action, you are adding alot of overhead to that single action. Obviously, this will matter only in some types of games.