I ran into a problem which I have not been able to find a solution for. This concerns the use of multiple aliases responding to the same action. I'll first describe my problem, and then the way I feel it ought to be fixed.
I have two plugins which need to work independantly from eachother. Both need to handle the 'sit' command. The first plugin, ProneHandler, will (globally) do this:
def DoSit(name, line, wildcs):
global VoluntaryProne
# Make sure we don't 'stand' again while roleplaying.
VoluntaryProne = True
world.Send("sit")
Another plugin, does the following (ok, this one is made up at the spot due to the actual code taking far more variables in account, which for this example would only distract):
def DoSit(name, line, wildcs):
if (not "needles" in Room):
world.Send("sit")
Now, the problem manifests itself when BOTH aliases are in effect. If only one is enabled, all works as it should.
Suppose, all is okay. Life is splendid and no dangers in sight. I 'sit'.
sit
sit
Oops, I'm sitting twice. Besides getting a tadbit spammy, I can live with that.
Now suppose, there are needles in the room, but I, the silly one, never noticed. I decide to 'sit'. What will the plugins, 'correctly', do?
sit
Oops, I just impaled myself. The poison on the needles will surely kill me. Atleast I'm not standing up again, like I should. Yay?
I've been searching for a way to solve this problem, and I think there is no reasonable way to solve it without having to write 'compatibility' code with other plugins. (Some may want to suggest 'oh, but use world.Execute(), or maybe keep_evaluating'. Been there, done that, got looped horribly bad. keep_evaluating does not solve this problem either, as plugins would need their sequence set to values higher/lower than other aliases.) This is unacceptable, as you want other people to be able to script their things and not get it messed up.
My solution is as follows. Add a pass_through="y" to be able to be added to aliases. This would allow for them, if ALL aliases have it set, the command to transparently pass-through. If only a single alias has pass_through="n", then don't let it through. If someone decides not to let something pass through, then that plugin can be decided to be an incompatible factor.
Of course, this still leaves the problem with the 'if'. Suppose I have yet another alias for 'sit', made by the user itself. He too, wants to check by using 'if', and only let the command through conditionally. World.Send("sit")... oops, same problem again.
So, an addendum would be to add the following (since I don't think return values work):
world.AllowAliasPassThrough(boolean PassesThrough)
This would -not- change the definition of the alias, but merely affect the way MUSH interprets this triggering of the alias. The needles-code would become as simple as this (with pass_through="y"):
def DoSit(name, line, wildcs):
if ("needles" in Room):
world.AllowAliasPassThrough(False)
One last thing...
If I missed something obvious in the help file or on the forums that deals with this situation, tell me? :) |