|
It's a lua plugin script that contains a table that should be only changed through the plugin functions. If the user accidentally changes the table it will mess up the functionallity of the plugin. most of these users are no programming experts, so I'd like to make it as easy for them as i can. I havn't got much knowlege about setmetatable and getmetatable, so would it be wise for me to just let this be and not make the table read only? -------------------------------------------------- From: "Sam Roberts" <vieuxtech@gmail.com> Sent: Wednesday, June 17, 2009 7:12 PM To: "Lua list" <lua@bazar2.conectiva.com.br> Subject: Re: Read only tables.
On Wed, Jun 17, 2009 at 9:37 AM, Imagine Programming<contact@imagine-programming.com> wrote:I've noticed, it doesn't make it read only again. Would I have to first set the metatable, and then only change the index every time? from nil to ronly() ?You have to not store the key/value pair in the actual table, you have to store it in some other table, so all reads and writes go through __index and __newindex. Or just don't make it read-only. What are you trying to achieve? Cheers, Sam __________ NOD32 4163 (20090617) Informatie __________ Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem. http://www.nod32.nl