I had this crazy idea yesterday, and wonder if anyone else ever pursued this.
The use case I was considering was an item which acted as a kind of locked container. Say you give a PC a box that they can't open at first, but it has some things inside that they will want later, and these things are randomly generated from a list.
Well I couldn't figure out how to make a locked carriable container, so I created a "Crate" item using a box icon I had in Miscellaneous Medium (its a custom icon). And when this crate is dropped on the ground it becomes a Crate placeable (an unopenable crate) that can be "taken" as part of its use action in which it becomes an item again. Having the item become a placeable is useful because it allows the PC to smash the crate to open it, and I can spawn objects in its death script.
All this was fine except I didn't have a clean way to track the things stored inside the crate.
Then it occurred to me. What if I had one string in which I could encode various directives in sequence? And since its just one string, I can easily copy this string from item to placeable to item. I don't have a ton of local variables to propagate back and forth.
Has anyone done this? The idea is that the string would be kinda like JSON data. A big string of code that can be executed.
it would be structured something like this:
DIRECTIVE directivetype : ARGUMENTS arg1 . arg2 . arg3 . : *
DIRECTIVE is a tag so that I know the text between DIRECTIVE and : is an identifier for the kind of directive.
ARGUMENTS is a tag noting that the string between it and the : is composed of arguments to be used by directivetype. different kinds of directives would take different arguments, and have a . as a delimter.
the * is a delimiter allowing multiple DIRECTIVES to be chained together
Anyway… its a silly idea, but if I had a nice framework for it, a single string could allow an item or placeable to do all kinds of things.
For storing items in an object I was thinking of having an inventory directive with an argument which is a label of a persistent container in the database which contains the object's contents. The death event and other "userdefined" open the box events would access the inventory directive.
Example:
Death event executes.
string sDirectives = GetLocalString(OBJECT_SELF, "SPECIAL_DIRECTIVES");
if(FindSubString(sDirectives,"INVENTORY")!=-1)
{
// parse directive string for inventory directives and execute them here
}





Retour en haut







