When is it an appropriate time to write your own plugin?

0 favourites
  • 9 posts
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • Coming from a professional C++ programming background, I thought I'd give Construct 2 a shot to see how quickly I could create something decent. I've been quite surprised with the results I've got in the two weeks I've really sat down and used it, but lately have started to wonder at what point is a solution better solved with a custom plug-in rather than using the event sheets? I've noticed there's a few third party behaviors and plugins that make it more convenient to achieve some more complicated behavior that could've been solved with event sheets - just not as easily, so perhaps I should consider writing more of those?

    For instance, in my game, you're able to construct platforms / conveyor belts which you do via dragging a strip. It was rather complicated using events to maintain an array of pieces so I knew where to move the end caps, and what "group" a piece of a conveyor belonged to (as you can swap their directions, each "piece" needed to know about the "whole" it made up). In hindsight, it probably would've been easier to write a custom plugin representing a "multi-sprite object strip" for my needs.

  • My reasons for writing a plugin/behavior are these:

    1. Adding a feature that events can't do.

    My paster/canvas plugins are an example of that. They add the ability to draw to a texture which isn't possible otherwise. I think another one was a spritesheet plugin.

    2. Interfacing with some existing JavaScript library or code.

    This kind of blends with one sometimes. Examples include the chipmunk behavior and the peerjs plugin.

    3. Speed improvements.

    The only example I had for this is my isometric behavior. I had it working with just events, but since it had multiple nested loops it wasn't very fast. Actually I think the sorting algorithm was O(n^3) worst case. There is some overhead with the event system so converting to js allowed me to sort 3x as many objects and still not affect the framerate.

    Other than that I'd avoid doing it for something specific to one project. Others do it, but for me it's more tedious.

    I'd recommend playing around with the sdk yourself though, it's fairly easy. I'm not sure it would be simpler to make your idea with a plugin than events though.

  • I actually had your plugins in mind when I was thinking of "the appropriate" time as you do seem to just fill holes in the feature set. I like this as a guideline for deciding. I had a mental back-and-forth about where at some point it didn't make sense to be using Construct 2 if I were just going to write plugins for everything, but I still do want to take advantage of it.

    As I'm gaining more experience, I'm coming up with little "paradigms" for common things I'm setting up - but sometiemes I just have the desire to make "boiler plate" algorithms easier to write.

    Anyway, thanks for the reply!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had made more than 200 plugins. I made plugins when

    1. porting other javascript library, or add other html elements, like R0J0hound said

    2. encapsulate logic, to reduce the complex of events.

    C2 programming is composed by events and plugins. The best way to treat events is using them as glue logic to manipulate plugins (objects).

  • Your #2 I suppose is what I was curious about more. I thought maybe I could make a plugin that lets you associate 3 Objects with it, representing each end cap and the "filler," and have the plugin manage most of the "increase / decrease" size logic rather than balancing it with events since it was about a dozen events and ~50 actions total to get that functional vanilla.

    I think I struggle mostly with not being able to pass around Object Types (like passing a a generic "create object" function an object type to create). I'm learning some workarounds to make that sort've thing easier and more natural to my mindset though. I think it's just adjusting to not having pointers.

  • I had made a plugin to create an instance by a string parameter. (source code)

    Get more help in this forums, or PM me.

  • Wouldn't a behavior work to associate a bunch of different objects?

  • rexrainbow - thank you for that. That's a good base for what I intend to do, and your ridiculous wealth of plugins is definitely a good learning tool! I think I can handle it from here, though may PM you if I have some questions with the SDK.

    newt - not sure exactly what you mean, but a custom plugin or behavior are probably both capable of doing what I wanted to do.

  • I'm pretty sure you have to have a plug for picking, but a behavior would be useful for after an object has been associated.

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