lua-users home
lua-l archive

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


I also thought of this method but I am still not sure how the following
would work.

Damage =
{
    { 5, 10, 15, 20 },
    { 7, 12, 17, 23 },
    { 8, 14, 19, 29 }
}

for key, value in Damage do
    CfgDamage( Damage[1], Damage[2] , Damage[3] )
end

Damage = nil

Unless I am mistake the code to fill Damage will linger.  Actually as I
write this I just realized that I could put all the code in a function and
then call the function and finally nil the function.

function CfgMain()
{
    Damage =
    {
        { 5, 10, 15, 20 },
        { 7, 12, 17, 23 },
        { 8, 14, 19, 29 }
    }

    for key, value in Damage do
        CfgDamage( Damage[1], Damage[2] , Damage[3] )
    end

    Damage = nil
}
CfgMain()
CfgMain = nil

  This will work but its prone to error since you are leaving it up to the
scripters to play nice and they never do :)

  Thanks for the pointers, maybe I should look into Virgil Smith's method if
its not too much work.  Man I wish I had started with Lua 5 :(

Leigh McRae
Lead Programmer
Rockstar Games Toronto
www.rockstargames.com


----- Original Message ----- 
From: "Nick Trout" <nick@rockstarvancouver.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Wednesday, October 22, 2003 2:03 PM
Subject: RE: One time scripts


>
>
> Leigh, assuming I have the jist of your question, functions are first
> class values in Lua, which means they are objects like anything else.
>
> function foo()
>  ...
> end
>
> foo = nil -- will release the function body (then GC)
>
> Functions are just closures of Lua code assigned to a variable name.
>
> I put some more details in the tutorial:
> http://lua-users.org/wiki/FunctionsTutorial
>
> You could however just define your functions in a table and delete this,
> e.g.
>
> config = {
>    width = 640,
>    height = 480
> }
>
> function config.foo()
>   ...
> end
>
> -- if none of table contents are referenced anywhere else, this will
> delete
> -- the functions as well.
> config = nil
>
> Regards,
> Nick
>
>
>
> > -----Original Message-----
> > From: Leigh McRae [mailto:leigh.mcrae@rockstartoronto.com]
> > Sent: Wednesday, October 22, 2003 7:06 AM
> > To: Lua list
> > Subject: One time scripts
> >
> > Using lua 4.01 and only one Lua_State, does anyone know how to make a
> lua
> > script be a one time only?  I have some config files I use lua for and
> I
> > can
> > set any of the tables in the script to nil but I still have the code
> > around.
> > I need a way to kick everything out that the file had.
> >
> > Leigh McRae
> > Lead Programmer
> > Rockstar Games Toronto
> > www.rockstargames.com
>
>