Plugins: Plugin versions and State Files, add "requires".

Posted by Magnum on Wed 05 Nov 2003 11:34 AM — 5 posts, 20,978 views.

Canada #0
Currently in Plugin State file:

<variables
   muclient_version="3.42"
   world_file_version="15"
   date_saved="2003-11-05 07:14:06"
  >

Currently in Plugin file:

<plugin
	name=""
	date_written = "2003-01-16"
	date_modified = "2003-01-16"
	version="1.0"
	requires="3.25"
	author="Magnum"
	id=""										<!-- /world.note world.getuniqueid -->
	purpose=""
	language="VBscript"
	save_state="y"
	>

Suggestion, put in Plugin State File:

<variables
   muclient_version="3.42"
   plugin_version-"1.0"
   world_file_version="15"
   date_saved="2003-11-05 07:14:06"
  >

and in main plugin file, put:

        ...
	version="2.0"
	save_state="y"
        state_requires="1.5"

Then, as you may have guessed by now, when the plugin is loaded, if the state file was created by a previous version of the plugin, and that version does not exceed the value of state_requires, then the state file is automatically deleted. If save_state does not equal "y", then the state_requires line is ignored if it exists.

In summary, this would allow a new version of a plugin to initialize as though it were a brand new plugin, in cases where it would be undesirable to work with a state file from a previous version.
USA #1
Hmm. For a moment I thought this might be a good idea, then I remembered that in each of the cases where I have used something like this, I require that some variables remain intact and that only the 'changed' or 'added' ones need to be adjusted. As long as you store all permanent data in a database or the like it would work though. Good idea.
Canada #2
The new tags would be backwards compatible. Only in the circumstance where the plugin author decided to use the 'state_requires' tag would old state files ever be deleted.
Australia Forum Administrator #3
Can't you just have a variable you add to the plugin, which is its version number? For that matter, GetPluginInfo already returns a version number (selector 19). You could move that to a variable.

Then in the OnPluginInstall you can check the version number in the variable, and if it is lower then your pre-set level, just delete or re-initialise what variables you want. That is a very general approach. This is backwards compatible too, because if the variable doesn't exist, you know you have a state file that is before you first added this variable to it.
Canada #4
Sure, could go about it that way.