miniwindow position save state oddness

Posted by George on Fri 15 Jul 2011 07:20 AM — 3 posts, 14,922 views.

#0
hi, I'm just starting to play with miniwindows and I'm running into some oddness that I'd like to understand.

Here's my basic plugin:


<script>
require "movewindow"

win = "test_" .. GetPluginID()

function OnPluginInstall ()

  windowinfo = movewindow.install(win, 12)

  WindowCreate(win, windowinfo.window_left, windowinfo.window_top, 200, 200, windowinfo.window_mode, windowinfo.window_flags, ColourNameToRGB("white"))

  movewindow.add_drag_handler(win, 0, 0, 0, 0, 10)

  WindowShow(win, true)
end

function OnPluginSaveState ()
  movewindow.save_state(win)
end

</script>


This works as expected, giving a draggable white square which saves its position when you close the world and reopen it.

However when I remove the plugin, close the world and reopen it, and then install the plugin again, the white square appears in the last saved position.

I'm assuming this is because the state file isn't cleaned up . The state file is saved to the worlds/plugins folder of the directory of the mushclient .exe, not the worlds/plugins/state directory (which I created first) as mentioned in the SaveState doc but I'm not sure if that doc is outdated.

Basically I'd like the old state to be removed if the plugin is removed then reinstalled -- what's the preferred way to do that? Or is this expected behaviour?


thanks, George
USA Global Moderator #1
Quote:
However when I remove the plugin, close the world and reopen it, and then install the plugin again, the white square appears in the last saved position. I'm assuming this is because the state file isn't cleaned up.

This is expected behavior. And I certainly don't want settings clobbered because the player temporarily removed a plugin.

Quote:
The state file is saved to the worlds/plugins folder of the directory of the mushclient .exe, not the worlds/plugins/state directory (which I created first) as mentioned in the SaveState doc but I'm not sure if that doc is outdated.
Huh. I've never had that happen.
Australia Forum Administrator #2
George said:

However when I remove the plugin, close the world and reopen it, and then install the plugin again, the white square appears in the last saved position.


I would not expect that removing a plugin (perhaps because you are having some clash of some sort with another plugin) should delete its state file. For some players the state file might contain months of gathered data (eg. mobs, friends) and they would be most upset if deleting the plugin removed its state file.

I would prefer if you had something like a "reset to defaults" action that cleaned up any variables that might be saved in the state file.

George said:

The state file is saved to the worlds/plugins folder of the directory of the mushclient .exe, not the worlds/plugins/state directory (which I created first) as mentioned in the SaveState doc but I'm not sure if that doc is outdated.


The documentation should be correct, does anyone else observe this behaviour? The state file folder is now saved in the "world preferences" database, from memory, so perhaps that got corrupted. I think that if it can't find the state file folder it asks you to choose one, so perhaps that is what you did.