Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: subspark on Fri 07/07/2006 06:12:01

Title: SUGGESTION: Ability to delete global variables
Post by: subspark on Fri 07/07/2006 06:12:01
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.
Title: Re: SUGGESTION: Ability to delete global variables
Post by: Kweepa on Fri 07/07/2006 07:26:01
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:

// 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?

// 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.
Title: Re: SUGGESTION: Ability to delete global variables
Post by: Gilbert on Fri 07/07/2006 07:48:47
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...
Title: Re: SUGGESTION: Ability to delete global variables
Post by: Radiant on Fri 07/07/2006 08:22:37
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.
Title: Re: SUGGESTION: Ability to delete global variables
Post by: subspark on Fri 07/07/2006 09:11:48
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.
Title: Re: SUGGESTION: Ability to delete global variables
Post by: SSH on Fri 07/07/2006 09:27:41
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.
Title: Re: SUGGESTION: Ability to delete global variables
Post by: subspark on Sat 08/07/2006 02:43:07
Sure why not. I guess my idealistic world of visual scripting is in vein.

I'll get to it via the script.

Cheers.