You may be over-engineering this it seems. How about a semicolon separated list of resrefs? Or pairs of resref;count;resref;count ...
Then you just parse the string and create the appropriate items.
For the more general question, there are a number of systems that do something like that for their specific domain
(NESS spawn names, NPC activities names etc). What kind of things are you expecting will be DIRECTIVES?
I guess that is what NESS does.
Is this over-engineered? Maybe. But I like the idea of one string for all that I need, because it is so easy to parse a string with the patterns I am using above, and I don't need to keep adding local variables to an object and updating my variable propagating script when an item is copied or changes type.
Other directives? Not sure yet. One idea is that I could have a system that identifies which events it responds to, and hooks up userdefined events to particular kinds of interaction, and then stick all of the code in one userdefined event script. Seems like an elegant way to do it. You could have one set of default scripts, a string of directives that configure which user defined events extend the default events, and then one user defined script to handle all the special cases.
I had considered making this only solve the inventory problem, but rather than a list of resrefs I prefer to hook a pseudo container to a saved "container" in the database. This allows the stored items to be dynamic and customized.
Why not just throw the crate into a database and retrieve it later?
Not sure what you mean. In one respective thats what I mentioned doing above for this one case. The string however would be one way of hooking the pseudo-container to a "container" in the database. The first part says that the object has inventory, and the second would be a database address to retrieve that inventory.
This allows me to create other ways of interacting with the crate and opening up this persistent inventory when the Player solves the lock or whatever.
----
And basically to clarify the problem that I am trying to solve:
local variables on an item are basically stored in an array on the object, but we don't access to the array in NWScript, so its a PITA to handle all the local variables on an object.
I use a boat load of local variables for a variety of things. For example, I have a conversation framework in which I pull out standard conversation phrases into data, and customize per NPC. I also have data for identifying type of NPC (Merchant, Inn Keeper, Leader, Priest whatever), strings which describe the NPC in the particular capacity and on and on and on.
Then I have my modification of Ambiguous Interactive Dungeons (basically a dumbed down interactive fiction parser) which relies on local variables on placeables to extend the object's functionality, hidden descriptions and so on.
With this much data piling up to customize everything, it has the potential to become unwieldy when I need to propagate the data from one object to another. If we had access to the array which stores all this it would be no problem.
So I was thinking… what if I had ways of compressing the data to essential strings…..
and this is what i came up with. And considering all that… maybe its time that I really started using NWNX. I keep trying to solve everything in NWScript. And at this point I basically need a web application to make it easier to build areas, and NPCs and so on with all the extra data i am using to define objects in the game. With a webapp hooked to the module and NWNX I could do all this on the module on the server. So many others do this, and as usual i am late to the party.