-------------------------------------------------------------------------------
--[[Tables]]--
local metaTableText = {'ok nope fam';'No.';'nah bro';}
local fenvModule = {};
local fenvData = {['print'] = print;}
local module = {}
-------------------------------------------------------------------------------




-------------------------------------------------------------------------------
--[[fenv Module]]--
do
    fenvModule.__index = fenvModule
    fenvModule.__newindex = function(t,i,v)
        if fenvData[i] then
            fenvData[i] = v
        end
    end



    function fenvModule.getfenv(state)
        if not _G[state] then
            _G[state] = {state = state;};
        end

        local self = setmetatable(_G[state],fenvModule)

        return self
    end

    function fenvModule.add(self,index,value)
        fenvData[index] = value
        return fenvData[index]
    end
end
-------------------------------------------------------------------------------







-------------------------------------------------------------------------------
--[[Functions]]--
local function unpack(t)
    return table.unpack(t)
end
-------------------------------------------------------------------------------









-------------------------------------------------------------------------------
--[[Module Variables]]--
local customFenv = fenvModule.getfenv(1)
local print = customFenv:add('print', function(typeNumberOrString,...)
    if typeNumberOrString == nil or (typeNumberOrString ~= 'number' and typeNumberOrString ~= 'string') then
        print(unpack({...}))
    elseif typeNumberOrString:lower() == 'number' then
        print(typeNumberOrString,string.gsub(unpack({...}),'%D',''))
    elseif typeNumberOrString:lower() == 'string' then
        print(typeNumberOrString,string.gsub(unpack({...}),'%A',''))
    end
end)
-------------------------------------------------------------------------------







-------------------------------------------------------------------------------
--[[Print Module]]--
do 
    module.__index = module
    module.__metatable = metaTableText[math.random(#metaTableText)]
    module.__newindex = function(table, index, value)
       if table[index] == nil then
           table[index] = value
       else
           warn(index,'is already localized in table.')
       end
       return table[index]
    end

    function module.new(...)
        local data = {}
        data.args = unpack({...})
        data.__index = data
        data.__metatable = metaTableText[math.random(#metaTableText)]
        data.__newindex = function(table, index, value)
            return 'No index can be added to this table.'
        end

        local self = setmetatable(data,module)

        return self
    end

    function module.updatePrint(self,...)
        local args = unpack({...})
        self.args = args

        return args
    end

    function module.print(self,repeatCount,typeString)
        coroutine.wrap(function()
            for i = 1, (repeatCount or 1) do
                print(typeString,self.args)
            end
        end)()
    end

    function module.doCheck(self)
        return getmetatable(self), getmetatable(module)
    end
end
-------------------------------------------------------------------------------







-------------------------------------------------------------------------------
do -- Script Logic
    local printModule = module.new('lol')
    printModule:print(2)
    printModule:updatePrint('b4tarbb')
    printModule:print(4,'string')
    printModule:updatePrint(printModule:doCheck())
    printModule:print(2)
    printModule:updatePrint('--------------------------------------------------')
    printModule:print()
end
-------------------------------------------------------------------------------

Just some feedback, please. This was scripted in a .lua file. I'm mainly looking for efficiency feedback and in what ways could this be used. How would you use it?

I don't know how to run multiple Lua files, so I put all modules together.

4 comments

0

Some parts are commented when they actually aren't. Don't be fooled.

0

i mean, if you have no use for it, why'd you make it?.. btw, just download the Lua Interpreter, and use the lua file.lua command, all other files have to be modules

0

arsubia12 shut up i do what i want you got me excited for no reason

0

well good luck smart mouth.. hff