SUGGESTION: Ability to delete global variables

Started by subspark, Fri 07/07/2006 06:12:01

Previous topic - Next topic

subspark

My game is constantly in need of new variables. But every once in a while a global variable is no longer needed and becomes obsolete to the function of the game. The clutter just keeps building up and it's particuarly distressing when trying to track every possible option avaliable to the player and remove bugs or conflicts. I can't make head or tails of it anymore.

I believe the deletion of global and room variables is just as important as creating them.

Cheers,
Paul W.

Kweepa

What are you looking for? Some way to automatically identify whether a GlobalVariable is referenced by the code? That's formally impossible, since (informally) you could have code like this:
Code: ags

// sets a global variable to a random value
SetGlobalVariable(GetVarIndex(), 3 + Random(15));

In any case, there's no need to delete these variables. You just reuse them.

Or do you mean global variables you have created in code?
Code: ags

// top of script
int globalIntegerForParticularPurpose = 1;
float globalRealThatINoLongerNeed = 3.14;

In that case, why not just erase the declarations when you no longer need them?
It would be possible to parse the scripts to find if the globals were unreferenced, but it's probably a lot of work for (I would guess) a little used piece of functionality.

If I have misunderstood, perhaps you could be a little more specific.
Still waiting for Purity of the Surf II

Gilbert

I think he meant there're some variables that were useful early in the game but not useful later. For example the game itself has two chapters, there's a variable boiled to keep track of whether a kettle of water was boiled in chapter 1, but when the player goes to chapter 2, the game background changes to space, and the kettle status is no longer important to the game, thus boiled is not useful anymore, so he wants to remove it.

However I don't see how this can be of much importance and worth the (probably very tedious) effort to implement - if you don't need it anymore, just reuse it or leave it alone...

Radiant

How about using more local variables instead? If the proverbial kettle is only found in one room, its boiling status has no business being a global var.

subspark

#4
My apologies. While not being a programmer as such I thought I was being as specific as humanly possible. There must be more to this story than I realised.

I am speaking of none other than the Interaction Editor. While finding it rather odd that the interaction editor is the only way to bring up the Global/Room Variables dialog box I can see there must be other methods for setting up global vars such as directly scripting them in.

My problem is, when I create a global variable from the Interaction Editor, I cannot edit the variable's names. This is a problem if I wish to recycle unused variables because, naturally, their names no longer bare relevance to the environment. I hope this is not what you were suggesting, Gilbot, as this can get even more messy than not using irrelevant named vars.

What I would expect is that when you fire up the Global/Room Vars dialog box and click edit, you would actually be able to edit the variable itself and not just it's value.

I hope this is clear enough.

Cheers.

SSH

CJ's said many times that the Interaction Editor stuff is really only there to get peopel started and he doesn't have many plans for improving it. Why not learn how to use variables in the script, as they are MUCH easier in the long run and easier to keep track of, if you give them sensible names.
12

subspark

Sure why not. I guess my idealistic world of visual scripting is in vein.

I'll get to it via the script.

Cheers.

SMF spam blocked by CleanTalk