plugin installation

BECOME PART OF THE COMMUNITY - Sign up here
  • Hi guys,

    I've created this plugin https://github.com/kevinhayen/grandma3_fixture_to_presets

    but have some questions regarding this installation.

    this plugin calls itself a few times using:

    Code
    local PluginName = select(1, ...)

    and

    Code
    Cmd("Call Plugin '" .. PluginName .. "'");

    for some reason, when opening a new showfile, editing a plugin, adding a ComponentLua, pasting the code, saving, rename plugin to "fixture_to_presets" , doing "reloadplugin", .. the plugin loads.

    But when doing an action where the plugin calls itselves, that "PluginName" variable is empty, and tells me:

    Code
    Illegal object: Call Plugin ""

    I get this working when I remove the ComponentLua and add it again, but it not always works from the first time. I'm curious what the reason can be for this?

    ----------------

    a second question is about this error:

    Code
    LUA Runtime Error[string "InsertFixtureswizard@insert_fixtures_wizard.lua"]:60: attempt to call a string value (global 'type')

    This error occurs when I try to open the patch screen where I need to select which fixture to patch, and I'm stuck in this screen:

    clicking "<select fixture type>" will give just this empty window:


    this error occurs when I first navigate within my plugin, mostly when moving from one attribute to another in my plugin, and when I then go to patch and press "insert new fixture".

    I tried to check the MA3 lua itself, I do know Printf() to print out a variable, but could not directly find what could go wrong.

    Also, in my LUA plugin, I never change any objects within grandma3, I only use info, so I'm confussed in why this error occurs.

    I'm curious if someone understands what can go wrong

    kind regards

  • Just had a quick glance at your +1000 lines plugin, so this comment is more of a guess but you could try it.

    With respect of your first question, You might try to call the lua function directly from lua instead of calling it with the go plugin command.

    The main problem I believe that you have in your plugin might be some global variables. Every variable that you use that is not specifically declared local with the local keyword in the first use, is declared global. Probably you use a variable called 'type' somewhere in the plugin that overwrites the lua keyword type. When this type variable is global, this will create a conflict when the console software uses the lua type keyword.

    Try to declare all of your variables, including functions and sub-functions local, except for those that you really need to be global (that might be none) In this case you might have to have the main function to be global so that you can call it from inside itself. Be especially careful with the names of any global function or variable (a function is in fact hold inside a variable). These names must be globally unique and you don´t know what other names are used by lua code inside the MA software, so use names that are not likely used by someone else.

    Edited once, last by A_art (January 30, 2023 at 8:24 AM).

  • I get this working when I remove the ComponentLua and add it again, but it not always works from the first time. I'm curious what the reason can be for this?

    your variable PluginName is assigned its value when the code is saved and loaded into the Lua engine

    You need to resolve the plugin name within the main function, if the name is expected to be changed after code is initialized

    local PluginName_at_code_load = select(1, ...)

    local ComponentHandle = select(4, ...)

    return function()

    local PluginName = ComponentHandle:Parent().Name

    end

  • The main problem I believe that you have in your plugin might be some global variables. Every variable that you use that is not specifically declared local with the local keyword in the first use, is declared global. Probably you use a variable called 'type' somewhere in the plugin that overwrites the lua keyword type. When this type variable is global, this will create a conflict when the console software uses the lua type keyword.

    well, this is a big breakthrough, I indeed used type as a variable.

    In fact, the error becomes more clear to me, just fixing this, thanks for this input !

    I will update my variables as you described

    Edited once, last by Haypro (January 30, 2023 at 10:58 PM).

Participate now!

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