Christopher Allan Webber

Christopher Allan Webber at

@Sean Tilley Good eye! First of all, commands and actions are not the same: "commands" are the user input an object can handle (such as "ring" in "ring bell") and which defer to an "action", which is what actors actually use to communicate to each other (a message has an action flag, and resolves to that). Messages are passed to action handlers (which are just procedures), and players never get to interact with this system directly, but that's how all the actors communicate with each other.

However, players do give text-based commands, like "ring the bell" and "sit on the couch" and "sign the form as deadsuperhero". These are commands! Commands take a few things: a verb, a command-handler (which includes a parser for the rest of the sentence and an assertion that the command really should go to this thing), and then... a mapping to an action! So yes, players never get direct mapping to actions (in a system like Guile, that would be a security risk), but their commands eventually transform into them, in a very controlled way.

Here's a problem though: what kind of commands should a actor handle? It turns out that you might want to handle different commands depending on your position in the location chain. The entire system in mudsync is based off of a tree: there's a toplevel object (which is simply the #f boolean), and then all rooms are children of that, and then everyone in a room is a child of that room, and all the stuff in your inventory is a child of you. So you can imagine being in a room: the room delegates a "say" verb to tell all participants in the room what you said, and that's the type of action as a container. Then there are all the co-occupants of the room, and these might have different verbs... eg you might "ring" the bell, or "take" the cuddles plushie. But then you might have different verbs when something is in your inventory: a sword might give you an "attack" ability, and you might want to eventually "drop" the plushie. Thus there are three command sets: "container-commands" (the room), "commands" (co-occupants of the room), and "contained-commands" (stuff in your inventory). (It's possible that the former and the latter should be renamed to "room-commands" and "inv-commands", even though it would be less accurate, but would be easier to remember the differences between.)

So, you can patch together groups of commands and actions willy-nilly; you don't have to rely on a complicated inheritance system. You want to be able to have a common take/drop command on this item? Sure! But maybe it's kinda pokemon-like, and you need to add a bunch of capture/foo verbs. Okay... now maybe it also needs to be able to dig into the ground because it has a special power where it can be used as a drill. But you also have a shovel, and you might as well have the same commands/actions for that.

Whew! That's a lot of things to compose. And in the current system, each of these things are built on simple lists (the O(n) cost is not severe becasue you're unlikely to get much higher than a few dozen on any given object) which means you can append them together to make just the set of things you need.

Of course, if you're making a pokemon-like thing, maybe all pokemon-like things have the same verbs, and kind of do inherit, and every object in the system inherits from , so it needs those methods, so for convenience I build not only thing-commands but also thing-commands*, which has the gameobj stuff pre-appended, so if you're just whacking on a couple of small additional features, you don't have to remember to add gameobj-commands if you're already adding thing-commands. Of course these map to actions so now you have to remember that all over again with the gameobj-actions and thing-actions!

So the short of it is: you can compose an actor to reuse multiple actor and command components, but the composition does not presently look very nice. It's a lot to keep track of. The good news is: it's in a ripe space for an additional abstraction that groups together command/actions into bundles and allows you to easily just say "I want the commands/actions from diggable-stuff and pokefoo-stuff" and it should be able to just easily glob all of that together.

That needs to be written, but it's on my mind.

This stuff is actually pretty simple, but it's kind of a lot of unnecessary wiring for the user right now, so I thought I'd explain in depth on how it works and why it's as complicated as it is. I hope to make it less complicated soon! Only so much time in the jam, and all that...

Hope that was interesting!

Jason Self, Sean Tilley likes this.

Christopher Allan Webber shared this.