PDA

View Full Version : plugin.Version doesn't update without exiting game


K1R4D3L
05-12-2012, 12:04 PM
Anyone else run into this? It seems that plugin.Version doesn't return an updated number unless you fully exit and re-open the game client.

This is a problem for me with my next release of KillTracker, since I'm changing the save file format somewhat. In testing, if I load v0.9.3, let it save it's files, stay in the game and go copy v0.9.4 into the Plugins folder, then unload and reload KillTracker, it will save its files with v0.9.3 as the version number, but in the v0.9.4 format. Then if I exit and re-open the game, it fails to load the files correctly because it sees that the version is now v0.9.4 from plugin.Version, that the files are tagged as v0.9.3, and tries to open them in v0.9.3 format and convert them, which it obviously can't do.

Sorry, bit of a messy explanation...hope you follow.

Only solution I can think of is to hard-code the version number in the code...which is eventually bound to bite me when I forget to update it in yet another spot when I put out a new version. Anyone have a better work-around, apart from telling users to exit the game before upgrading and hoping they actually do?

moebius92
05-12-2012, 12:28 PM
I use plugin:GetVersion(), so I've no idea about plugin.Version - I get a nil when I try to access that, but doing a "/plugins refresh" seems to update the version for me.

K1R4D3L
05-12-2012, 01:56 PM
It apparently depends on how you get your plugin object which way you get the version out.

for _, plugin in ipairs(Turbine.PluginManager.GetAvailablePlugins() ) do
if (plugin.Name == "KillTracker") then
Turbine.Shell.WriteLine(""..plugin.Version);
--Turbine.Shell.WriteLine(""..plugin:GetVersion()); --fails
end
end
--Turbine.Shell.WriteLine(""..Plugins["KillTracker"].Version); --fails
Turbine.Shell.WriteLine(""..Plugins["KillTracker"]:GetVersion());

Either way though, the working command returns the old version until you either exit the game and re-open, or, you're right, run "/plugins refresh" or hit the refresh button in the plugins manager (I'd never used these for anything).

I'm still concerned that users aren't going to refresh and are just going to load the new version, causing problems. If there wasn't a data corruption risk, it wouldn't matter so much, but as much as I don't like it, I think I'm going to have to hard-code the version in the code and maintain it.

K1R4D3L
05-12-2012, 02:23 PM
Ahh, never mind...I'm an idiot. I found a fourth way to refresh the plugins, and unlike the other three, this one can be done programatically. Don't know how I missed it:

Turbine.PluginManager.RefreshAvailablePlugins()

I just call it before I pull the version number. Problem solved.