My query today concerns the order in which objects are listed in the game when they appear together in a particular context or in your inventory.
The simplest way to control their order is obviously by changing the order in which the objects are introduced in your source. But that initial order gets changed if you pick up and drop things. Normally this isn’t something that would bother people, or me, but in this case I do want to preserve the initial ordering of all gettable items in the game across all situations and contexts (EG - whether we see them in a room, or in my inventory, or in a list of what I’m wearing… if the comb is item 3, it should always appear in lists before hairspray, item 5) – how could I go about this?
Btw all my gettable items already have item numbers explicitly assigned to them in my code.
EG - The itemid of comb is 3. The itemid of hairspray is 5.
Actually, I already realised I don’t need this behaviour in room content displays, only when inventory-ing and wearing. And in those cases, I’ve already written custom code. I just need to change it further to print out the objects in itemid order.
I’d still be interested to know how to effect my original non-trivial request, but also I encourage everyone to not spend their time on it now that I don’t Need to know.
There is no tidy way to do this. You’d have to write code before any given list-writing event, yanking objects out of the world and then replacing them in the desired order. (Or the reverse of the desired order, I think.)
To approach the idea from a similar but different angle (and tell me if this is a dumber way of doing it) I thought I could physically re-order the items not before list-writing, but just as part of any event which changes their position in the world. Getting, dropping, wearing, removing, items being added to or removed from rooms. Because this would happen less often than list-writing, right? At such times I could jump to a subroutine which does the in-and-out-of-the-world shuffling.
I’m not sure. It may depend on play style and game style. I lean towards doing the manipulation at list-writing time because (a) it avoids the chance of your setup being borked by an un-accounted-for library action and (b) it’s similar to the rearrangement that the library already does with list_together.