Call a ComponentLua

BECOME PART OF THE COMMUNITY - Sign up here
  • As far as I can tell all Plugin components are loaded into the same name space. provided the function is not local you can just call it from the any other plugin. I suspect there might be a better way to do this but looking at the built in plugins this is how they do it.


    So if you have two LUA files loaded into your XML:

    file1.lua

    file2.lua


    And in file2.lua you have the following function:

    Code
    function fromFile2()
    Echo("This if from file 2")
    end

    and the following in file1.lua:


    Code
    Echo("This is from file 1") -- prints this is from file 1
    fromFile2()                 -- prints this is from file 2

    also looking at the hardware test plugins you probably want to make the global functions Globally unique by making your own "namespace" so you don't end up with Collisions. For example:


    Code
    function MYPLUGIN:fromFile2()
    Echo("This if from file 2")
    end



    Code
    Echo("This is from file 1") -- prints this is from file 1
    MYPLUGIN:fromFile2()                 -- prints this is from file 2