[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table function
- From: Luiz Henrique de Figueiredo <lhf>
- Date: Mon, 29 Apr 2002 09:28:18 -0300
>Hello, I'm trying to get a table function to nil the variable that it was
>assigned to. just like this:
>
>reddog = Load_Sprite( "reddog.dat" ) --This assigns { NAME = "reddog.dat" }
>to reddog.
>
>reddog.Kill() -- I want this to do reddog = nil
Why not do "reddog = nil" then?
Another solution, which just might be adequate for you, is to have
Load_Sprite receive ""reddog", create a table as before but with an extra
field to hold the var name:
function Load_Sprite(prefix)
local t={ NAME=prefix..".dat", PREFIX=prefix, Kill=mykill }
setglobal(prefix,t)
return t
end
function mykill(self)
setglobal(self.prefix,nil)
end
Use it as "reddog:Kill() "
--lhf