Lua obj manipulation for hardco(re)der

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Lua obj manipulation for hardco(re)der

Post 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.
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Lua obj manipulation for hardco(re)der

Post 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.
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Re: Lua obj manipulation for hardco(re)der

Post 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.
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Lua obj manipulation for hardco(re)der

Post 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. :(
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Re: Lua obj manipulation for hardco(re)der

Post 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 ?
What Is Your Quest ?
Post Reply