PluginVars : Getting "wrong parameter #1"

BECOME PART OF THE COMMUNITY - Sign up here
  • So... the docs are saying is (I don't even bother to complain about the docs):

    PluginVars([string: plugin name]): light userdata: plugin variables
    and
    GetVar(light userdata: variables,string:varname): value

    I tried:

    Code
    local pluginName = select(1, ...);
    
    function main()
     local pv = PluginVars(pluginName)
     SetVar(pv, "someName", "some string value")
    end
    
    return main

    But I get:

    Code
    wrong parameter #1
    SetVar (...)
    SetVar is expected to be used with type Variables (or derived)


    I can't understand this error.
    So I tried :

    And I get the same error on the "SetVar(pv,...)" line

    I don't understand this, this can't be a syntax error if both pv and uv are of type "user data", can it?


    Any ideas how I should be Using PluginVars?

  • the actual functionality has changed for this function

    maybe this "bugfix" can be helpful

  • Thanks !

    A couple of thoughts:
    1) Where did you find out about this change?

    2) I just realized that using pluginName as an argument for PluginVars is not safe, since the plugin can be renamed.
    2.a) Do you know of any uniq and consistent id for a plugin?
    That stays the same also if it is renamed or moved to another Pool index.

    I don't think this does the job:

    local my_handle = select(4,...);



    2.b) If there isn't any, then I guess PluginVars() would better be called something else, like FolderVars(), and you can choose any folder name you want.

  • 1) I merely assume that it has changed, as I expect that if this function when initially created, had the currently observed functionality, then it would have been created with a different name and description.

    2) use a fixed name

    local pv = PluginVars('StorageContainerForMyGreatPlugin')

    (assuming you want copies/duplicates/imports of the plugin to use the same/existing container)

    2.a) use the string representation of the plugin's handle as name:

    local componentHandle = select(4, ...)

    ---

    local uniqueName = HandleToStr(componentHandle:Parent())

    2.b)

    To my understanding, the main/initial purpose for this function is to preserve settings of the internal/UI plugins (Menu keyword), as the Menus have a fixed name, and the preferences and vars are not only userprofile, but also screenconfig specific:

    Echo(pv:AddrNative())

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!