Skip to content
This repository has been archived by the owner on Dec 16, 2018. It is now read-only.

Adding glove to the love namepace #7

Open
pablomayobre opened this issue Nov 24, 2014 · 1 comment
Open

Adding glove to the love namepace #7

pablomayobre opened this issue Nov 24, 2014 · 1 comment

Comments

@pablomayobre
Copy link
Contributor

It would be nice to have an option to add glove to the love namespace. This way you could do something like

local glove = require "glove"
glove.love()
love.filesystem.mkdir("Hello") --And this would work like glove.filesystem.mkdir

glove.love could be something like this

glove.love = function ()
    if love then
        for k,v in pairs(glove) do
            if type(v) == "table" then
                for j,u in pairs(v) do
                    love[k][j] = u
                end
            elseif k ~= "love" then
                love[k] = v
            end
        end
    end
end

Kind of like deep copying, this would allow to add the new function without destroying the old ones. A backup would be nice too

oldlove = deepcopy(love) --This should be run before glove.love

Deepcopy is needed for the backup otherwise this wont copy the items right

@Bobbyjoness
Copy link

This would not work. This causes an infinite loop.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants