Quick Pick



Dec 29, 2013

The Variables Binder or How I Made Something Easy Even Easier

Faithful users of my works know that I like event-controlled system, when appliable. For example, my Balloon Messages System relies not on clumsy commands input in messages or stuff like that, but rather on regular switches and variables, which are easier to handle. Those switches and variables are then read by the scripts which in turn do their job. To achieve this, the scripts have to know which switches/variables were appointed to this or that purpose, because from one project to another, a same switch/variable may very well have a different ID - like, if I use switches #2 and #3 in my demo, they might already be allocated, and you'd like to use other ones instead.

Up to now, you had to manually set up constants for that purpose. You had to choose free switches/variables in your project editor, then you had to open the script where the constants were set and replace each of them with the ID you'd chosen, and then it was all cool and easy. That was, until I decided I was too lazy to do the manual part anymore. I decided it was not that hard for the scripts to find the matching switches/variables after all and they could very well do it on their own. From that decision, a new script was born. Behold... here's the Variables Binder!



So what does it do?

Basically, automate the process of binding switches/variables as set in the project editor with the scripts. Say you install the Balloon Messages System to your project, you run it just after, then return to your project editor and poof! a couple of variables and switches which control this system have installed themselves in free slots, saving you the trouble of naming them manually. From then on, those switches/variables will automatically be recognised by the script you've just installed and you don't need to worry about that anymore. So, in short, it's simple as 1-2-3.



Any recommendations?

The Variables Binder will never ever mess with switches/variables which already have a name so it's absolutely safe to use on a project you have already started a while ago - however, it decides whether a switch/variable is free based on whether its name is empty or not, so make sure all of the switches/variables you're using at this time have a name, otherwise you could get surprises.

You can see that your newly named switches/variables have got a tag before their name. This makes it easier to see which variables group together, but it also works as an identification code. That is, you're free to rename the switch/variable as long as you keep its tag intact.

If you were already using one of my event-controlled scripts prior to the arrival of the Variables Binder, please make sure the variables you've set manually have the exact same name (without the tags) as in the original demo, since when the tag is absent, the Variables Binder will identify them based on their name, and automatically add the matching tag - so you end up with the exact same settings as if starting a fresh new project with the scripts' latest version.

If the switches/variables have not been installed prior to the Variables Binder's first launch, it will claim the first free slots it can find, so you might want to have several of them in a row so that they don't get scattered. Also, make sure you have set the maximum number of items so that there's enough room for the newcomers in the first place!



What if I still want to set the variables manually?

If you're not satisfied with the Binder's automated setup for whatever reason, there's nor problem at all. Just cut/paste the name of the variable you want to move to another slot. Since the setup is dynamic, the script will recognize the newly named variable as if it had set itself up on the next time you run the game.



Where can it be found?

The Variables Binder is part of the latest version of my Common pack. You should re-download it to ensure compatibility with my future scripts.

2 comments:

  1. :) Je suis content de voir du développement sur ton blog ! J'espère que tu as passé de belle fête ! et une joyeuse année en avance !

    ReplyDelete