Closed nww02 closed 2 years ago
Is the issue the "You can't do that"?
Sample code:
start_at = my_location
locations {
my_location : location "You are in a room.";
}
on_command {
: match "test _" {
: mask {
: print "Should print";
: done ;
}
: print "Should not print";
}
: match "test2 _" {
: mask {
: print "Should print";
: return ;
}
: print "Should not print";
}
}
Imagine having a bool to toggle whether the default handler should fire.
typing "true / false" should switch the behaviour when typing 'test'.
start_at = my_location
locations {
my_location : location "You are in a room."
{
on_command {
:match "true -" {
:set_true "my_bool";
}
:match "false -" {
:set_false "my_bool";
}
:match "test -" {
:mask {
:print "Location Handler Fires.";
:if (my_bool){
:done;
}
}
}
}
}
}
on_command {
:match "test -" {
:mask {
:print "Global Handler Fires.";
:done;
}
}
}
booleans {
my_bool : boolean "false";
}
I've just checked 74m and it DOES seem to be allowing :done to terminate execution of the user-code handlers, but doesn't stop the main parser firing (So always getting "you can't do that").
Fixed in beta 74r.
There are many cases where I want a subroutine to calculate something, and then decide whether to take an action or just let the default parser kick in. Unfortunately even the act of setting a variable will halt the flow in the match block, so I have to wrap anything "quiet" in a mask: However, what do I do if I really DO decide that I need to terminate the flow?
I need to put the :done; outside the mask. But that means I need to create a new variable , let's say "actually_done", and pass it outside the mask block:-
This would be cleaner if one could just :-
Calling 'done' from within a mask could probably be taken as a sign that the developer DOES want to affect the parse flow. There's "return" for non-interference options, after all, or simply just letting it fall through.