ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

Rewriting cannot work with local event handlers #499

Open joshgoebel opened 2 years ago

joshgoebel commented 2 years ago

Sentence rewriting (or prefiltering of input) seems impossible with local event blocks (on_command, etc).

What I have:

locations {
 cliffside_east: location "..." {
  on_command {
        :match "x vine; x vines" {
          :print "As thick as your arm.";
        }
 }
}

on_command {
  :gosub "sentence_rewriting";

  :if (inputs() > 2) {
    :print "This game requires only two word inputs.";
    :done;
  }

Someone types: look the vines

What I expect:

This game requires only two word inputs.

What I see instead:

As thick as your arm.
This game requires only two word inputs.

Suggestion

It feels like there should be a pre_on_command block that allows analyzing/modifying input BEFORE it hits any on_command handers at all... I tried this using on_describe and on_pre_describe but those don't seem to allow handling input for some reason.

A magic subroutine might also do the trick... (but need good docs)... like say if there was a adv_rewrite it would also be called first, automatically. And it could be used for validation, rewriting, etc...

joshgoebel commented 2 years ago

I tried this using on_describe and on_pre_describe

But those actually make no sense since they are per describe, not per command... we need an early hook that runs per command...