lua-users home
lua-l archive

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


Hi,

I'm currently using lua as a configuration parsing tool where users
create config files like:

speed=100
bounciness=20

I'm using meta tables to chain these together so users get a sort of
'scope hierarchy' - ie: 'inner' configs can override settings in outer
configs.

This works well for reading values but not for writing, because the
way lua works, an assignment like 'speed=100' will overwrite the outer
speed value.

The behaviour I'm after would instead create a new key/value in the
inner scope if it didn't exist there already.

Is there anyway to do this without resorting to either a C function to
do the metatable set_index work, or having to littler the config files
with something like 'self.speed=100'?

Thanks in advance for any advice.

Bye!
Mark