Page 1 of 1

Lua obj manipulation for hardco(re)der

Posted: Thu Feb 18, 2010 6:57 pm
by Joramun
Ok, it must be something a bit backward-awkward-compatible, but here is something I just thought of:

Using the obj.archetype table as a metatable for the instance exvar[id] table:

For each base dsb function that looks for info into an instance's archetype, INSTEAD look for the same info in the exvar[id] table.

So that the info is not lost or copied every time, for each instance that is spawned or qswapped, do: set metatable of "exvar[id]" to be "obj.arch"

I hope I make sense. That would allow some very interesting stuff to be done quite easily.

Re: Lua obj manipulation for hardco(re)der

Posted: Thu Feb 18, 2010 7:31 pm
by Sophia
I'm assuming the goal of this is to be able to override a certain arch property for a given instance without having to create a whole new arch just to change that one thing, right?

That is, you could set the mass of one individual "rock" to be 5.0kg, or whatever.

Re: Lua obj manipulation for hardco(re)der

Posted: Thu Feb 18, 2010 7:38 pm
by Joramun
Yes, or not bother specify different archetypes for each "torch level", discharged spell_casting_item etc.
It would also be useful for monsters and other unpredictable application of this.

But I agree it would probably require a lot of work and break backward compatibility with some dsb-lua code.

Re: Lua obj manipulation for hardco(re)der

Posted: Thu Feb 18, 2010 7:58 pm
by Sophia
For things like torch level, it's kind of tricky because certain arch properties-- such as the icon used-- are cached by the engine for speed and ease of access, so this method wouldn't work without a whole big mess. :(

Re: Lua obj manipulation for hardco(re)der

Posted: Thu Feb 18, 2010 8:25 pm
by Joramun
Don't bother, I'm just thinking out loud and leaving my ideas there on the forum,
so that they don't turn round and round in my head like a gold fish in ... grey matter ?