lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Here in rainy old London it just turned 9am :)

 

From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of bravefly
Sent: 25 March 2010 08:18
To: Lua list
Subject: RE: Cleaning up specific lua scripts

 

Ricky , what's the time now?

 

 

2010-03-25


bravefly


发件人: Ricky Haggett

发送时间: 2010-03-25  16:14:42

收件人: 'Lua list'

抄送:

题: RE: Cleaning up specific lua scripts

Pierre,

This is a simpler and more elegant version of what I implemented yesterday afternoon, which also seemed to do the job, albeit with more fuss..  I'm definitely going to upgrade to your code today..

Thanks,

Ricky

-----Original Message-----

From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Pierre-Yves Gérardy

Sent: 24 March 2010 19:27

To: Lua list

Subject: Re: Cleaning up specific lua scripts

On Wed, Mar 24, 2010 at 12:30, Ricky Haggett <ricky@honeyslug.com> wrote:

> Yep, we could store a table of all of the functions / tables within a

> specific level script, but it would be awkward for the designers to

> maintain, and a potential source of error...

You could also do it the other way around:

after you've loaded your global scripts do

globals={}

function cleanLevel()

    for k,_ in pairs(_G) do

        if not globals[k] then _G[k] = nil

    end

end

for k,_ in pairs(_G) do

    globals[k]=true

end

globals will index all globals present at that point (including itself

and cleanlevel() ), and cleanLevel() will only delete the globals not

referenced there. Case solved :-)

Cheers,

-- Pierre-Yves

No virus found in this incoming message.

Checked by AVG - www.avg.com 

Version: 9.0.791 / Virus Database: 271.1.1/2767 - Release Date: 03/24/10 07:33:00

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.791 / Virus Database: 271.1.1/2767 - Release Date: 03/24/10 07:33:00