Add a shared table to the lua envirorment.


  • Project Moderator

    Feature:
    Add a shared table to the lua script envirorment.
    Description:
    Add a table that is shared between all lua scripts so scripts can exchanged data and functions.
    Motivation:
    This feature should be added to the client, so plugin developers can offer functionality or data to different plugins.
    An example would be creating and sharing a function called registerCommand in @Rektinator 's PlutoAdmin script and using it in a different script to add a command to his script if it is used on the server. That way our script could either run as a stand alone plugin or as a addon of PlutoAdmin script.

    Expose a function:

    function registerCommand(name, alias, level, funcName, func)
        newCMD = {}
        newCMD.name = name
        newCMD.alias = alias
        newCMD.level = level
        newCMD.func = funcName
        newCMD.enabled = true
        table.insert(settingshandler.settings.commands, newCMD)
        commands[funcName] = func
    end
    _S.pa_registerCommand = registerCommand
    

    Using the exposed function:

    if _S.pa_registerCommand ~= nil then
        _S.pa_registerCommand("mycommand","mc",0,"myfunction",myfunction)
    else
        -- Register callbacks and provide our functionality as a (chat) command on our own.
    end
    

  • Banned

    Sounds pretty neat tbh