Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaner way for scripts to handle being invoked at runtime #44

Open
dewiniaid opened this issue Dec 4, 2019 · 0 comments
Open

Cleaner way for scripts to handle being invoked at runtime #44

dewiniaid opened this issue Dec 4, 2019 · 0 comments

Comments

@dewiniaid
Copy link

A number of scripts are designed to be persistent, and it is frequently useful to be able to pass commands to an already-running script.

Currently, the only good option to do so involves an UpstreamHook that does the equivalent of capturing /^(?:<c>)?\s*#{Regexp.escape("#{$lich_char}#{script.name}")}(\s+.*)?$/ and parsing commands in such a hook.

This has a number of problems, notably:

  • Each script that does it requires an UpstreamHook, which adds a (tiny) amount of input lag to the game
  • Commands captured in this way either need to have the full name of the script (rather than a shortened form) or risk false positives. (Should ;tri be interpreted as a command to ;triage or a request to invoke ;trigger?)

My proposed solution would be to add, as an API, something like this:

on_reinvoke {|args|
    # args would be the equivalent of `script_args` as it exists in @@elevated_script_start
}
# Non-forced invocations of this script instead call this block, akin to before_dying

on_reinvoke(nil)
# Revert to default (old) behavior 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant