From 9eec0b3eb8ba409d19495d8737e3f2de8566af34 Mon Sep 17 00:00:00 2001 From: vtcifer Date: Fri, 13 Sep 2024 15:19:40 -0400 Subject: [PATCH 1/4] Initial commit of script-watch.lic --- profiles/base-empty.yaml | 1 + profiles/base.yaml | 35 +++++++++++++ script-watch.lic | 103 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 script-watch.lic diff --git a/profiles/base-empty.yaml b/profiles/base-empty.yaml index 2a4f750e55..f49cac09ec 100644 --- a/profiles/base-empty.yaml +++ b/profiles/base-empty.yaml @@ -128,3 +128,4 @@ empty_values: weapon_training: {} whirlwind_trainables: [] zombie: {} + script_watch_ignored_scripts: [] diff --git a/profiles/base.yaml b/profiles/base.yaml index 6e3b1aeb96..f11bff344e 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -2618,3 +2618,38 @@ tome_settings: - crossing-repair - task-forage debug: false + +# script-watch.lic settings: +# display scripts hidden by hide_me (if false, only scripts listed by `;list` will be shown) +# if true all scripts in `;listall` will be shown, except for those listed in in `script_watch_ignored_scripts`` +script_watch_display_hidden: false +# show script arguments after the script name +script_watch_display_arguments: true +# enable click on script name to pause/unpause script +script_watch_enable_links: true +# list of scripts you never want shown +script_watch_ignored_scripts: + - dependency + - drinfomon + - spellmonitor + - events + - skill-recorder + - moonwatch + - roomnumbers + - textsubs +# lower number means faster updates, but could have performance impact +script_watch_cycle_time: 5 +# All the next settings control output format in the window: +# They also need to be properly escaped XML/strings +# the default settings would result in output that looks similar to this: +# [afk] | [jail-buddy] | [t2] | [burgle] - , , | [go2] - <1234> +# What the name of the script should be surounded by, and what should be between scripts +script_watch_script_prefix: "[" +script_watch_script_postfix: "]" +script_watch_script_separator: " | " +# if arguments are turned on, what should separate the script name and the argument list +script_watch_script_argument_separator: " - " +# if arguments are turned on, what should the arguments be surrounded by and what should be between each argument +script_watch_argument_prefix: "<" +script_watch_argument_postfix: ">" +script_watch_argument_separator: ", " diff --git a/script-watch.lic b/script-watch.lic new file mode 100644 index 0000000000..7c81e43a3d --- /dev/null +++ b/script-watch.lic @@ -0,0 +1,103 @@ +=begin + Creates a script window and keeps list of scripts in it + It can be clickable to pause/unpause scripts as well\ +=end + +# custom_require + +no_pause_all +no_kill_all +hide_me + +class ScriptWatch + def initialize() + settings = get_settings + @display_hidden = settings.script_watch_display_hidden + @display_arguments = settings.script_watch_display_arguments + @enable_links = settings.script_watch_enable_links + @ignored_scripts = settings.script_watch_ignored_scripts + @passive_timer = settings.script_watch_cycle_time + + @script_prefix = settings.script_watch_script_prefix + @script_postfix = settings.script_watch_script_postfix + @script_separator = settings.script_watch_script_separator + + @script_argument_separator = settings.script_watch_script_argument_separator + + @argument_prefix = settings.script_watch_argument_prefix + @argument_postfix = settings.script_watch_argument_postfix + @argument_separator = settings.script_watch_argument_separator + @last_update = Time.now + + # hide myself + @ignored_scripts.push(Script.current.name) + + @script_list = [] + @script_output = '' + _respond("") + _respond("") + + loop do + output_scripts() + pause @passive_timer + end + end + + def output_scripts() + temp_list = @display_hidden ? Script.running + Script.hidden : Script.running + + @script_list = temp_list + + temp_output = temp_list.select { |s| !(@ignored_scripts.include?(s.name)) } + .collect { |s| + output = "" + output.concat @script_prefix + if @enable_links + case $frontend + when 'genie' + # use alternate link syntax for genie, so end users don't need to enable it globally + # enabling links generally in genie can cause issus with .NET UI. This link syntax + # bypasses the global setting, which *shouldn't* cause the kind of problems enabling + # links globally in genie can cause + # genie alternate link syntax: {:} + output.concat "{#{s.name}:#{$clean_lich_char}#{s.paused? ? 'unpause' : 'pause'} #{s.name}}" + else + # standard link syntax for Wrayth (and maybe others?) + # in theory frostbite should use this, but there is a bug with multiple links in one + # line with current version at this time - (DD: 2023-08-22) + # v1.16.0-beta was released 2023-02-05 + output.concat "#{s.name}" + end + else + output.concat s.name + end + output.concat @script_postfix + output.concat " (paused)" if s.paused? + + if @display_arguments && !(s.vars.empty?) + output.concat @script_argument_separator + output.concat @argument_prefix + output.concat s.vars.drop(1).join("#{@argument_postfix}#{@argument_separator}#{@argument_prefix}") + output.concat @argument_postfix + end + + output + } + .join(@script_separator) + + # attempt to short circuit to keep from sending unneeded xml, still update every 300s (5 min) + return if @script_output == temp_output && ( (Time.now - @last_update) < 300 ) + @script_output = temp_output + + _respond("\r\n") + _respond("#{@script_output}\r\n\r\n") + @last_update = Time.now + end +end + +before_dying do + # clear window + _respond("\r\n") +end + +ScriptWatch.new \ No newline at end of file From 762bc332251550af74f8ef28ff84cba801e3c6cd Mon Sep 17 00:00:00 2001 From: vtcifer Date: Fri, 13 Sep 2024 15:29:06 -0400 Subject: [PATCH 2/4] rubocop --- script-watch.lic | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/script-watch.lic b/script-watch.lic index 7c81e43a3d..204de0dbc0 100644 --- a/script-watch.lic +++ b/script-watch.lic @@ -17,11 +17,11 @@ class ScriptWatch @enable_links = settings.script_watch_enable_links @ignored_scripts = settings.script_watch_ignored_scripts @passive_timer = settings.script_watch_cycle_time - + @script_prefix = settings.script_watch_script_prefix @script_postfix = settings.script_watch_script_postfix @script_separator = settings.script_watch_script_separator - + @script_argument_separator = settings.script_watch_script_argument_separator @argument_prefix = settings.script_watch_argument_prefix @@ -44,19 +44,19 @@ class ScriptWatch end def output_scripts() - temp_list = @display_hidden ? Script.running + Script.hidden : Script.running + temp_list = @display_hidden ? Script.running + Script.hidden : Script.running @script_list = temp_list temp_output = temp_list.select { |s| !(@ignored_scripts.include?(s.name)) } - .collect { |s| + .collect { |s| output = "" output.concat @script_prefix if @enable_links case $frontend when 'genie' # use alternate link syntax for genie, so end users don't need to enable it globally - # enabling links generally in genie can cause issus with .NET UI. This link syntax + # enabling links generally in genie can cause issus with .NET UI. This link syntax # bypasses the global setting, which *shouldn't* cause the kind of problems enabling # links globally in genie can cause # genie alternate link syntax: {:} @@ -82,11 +82,12 @@ class ScriptWatch end output - } - .join(@script_separator) + } + .join(@script_separator) # attempt to short circuit to keep from sending unneeded xml, still update every 300s (5 min) - return if @script_output == temp_output && ( (Time.now - @last_update) < 300 ) + return if @script_output == temp_output && ((Time.now - @last_update) < 300) + @script_output = temp_output _respond("\r\n") @@ -100,4 +101,4 @@ before_dying do _respond("\r\n") end -ScriptWatch.new \ No newline at end of file +ScriptWatch.new From 9dd6fd21e5f1a7432da9bf4bf9daaddaf597a0d8 Mon Sep 17 00:00:00 2001 From: vtcifer Date: Fri, 13 Sep 2024 16:11:21 -0400 Subject: [PATCH 3/4] remove unneeded variable, more sensable indentation regardless of what rubocop says --- script-watch.lic | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/script-watch.lic b/script-watch.lic index 204de0dbc0..47dd23af31 100644 --- a/script-watch.lic +++ b/script-watch.lic @@ -32,7 +32,6 @@ class ScriptWatch # hide myself @ignored_scripts.push(Script.current.name) - @script_list = [] @script_output = '' _respond("") _respond("") @@ -46,8 +45,6 @@ class ScriptWatch def output_scripts() temp_list = @display_hidden ? Script.running + Script.hidden : Script.running - @script_list = temp_list - temp_output = temp_list.select { |s| !(@ignored_scripts.include?(s.name)) } .collect { |s| output = "" @@ -82,8 +79,8 @@ class ScriptWatch end output - } - .join(@script_separator) + } + .join(@script_separator) # attempt to short circuit to keep from sending unneeded xml, still update every 300s (5 min) return if @script_output == temp_output && ((Time.now - @last_update) < 300) From a0fb8b9da6dbf6bd24567b5aead079bc284b9f3a Mon Sep 17 00:00:00 2001 From: Derek Hoffmann Date: Sun, 6 Oct 2024 14:44:25 -0400 Subject: [PATCH 4/4] rubocop --- script-watch.lic | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/script-watch.lic b/script-watch.lic index 47dd23af31..45b02f3c66 100644 --- a/script-watch.lic +++ b/script-watch.lic @@ -47,38 +47,38 @@ class ScriptWatch temp_output = temp_list.select { |s| !(@ignored_scripts.include?(s.name)) } .collect { |s| - output = "" - output.concat @script_prefix - if @enable_links - case $frontend - when 'genie' - # use alternate link syntax for genie, so end users don't need to enable it globally - # enabling links generally in genie can cause issus with .NET UI. This link syntax - # bypasses the global setting, which *shouldn't* cause the kind of problems enabling - # links globally in genie can cause - # genie alternate link syntax: {:} - output.concat "{#{s.name}:#{$clean_lich_char}#{s.paused? ? 'unpause' : 'pause'} #{s.name}}" - else - # standard link syntax for Wrayth (and maybe others?) - # in theory frostbite should use this, but there is a bug with multiple links in one - # line with current version at this time - (DD: 2023-08-22) - # v1.16.0-beta was released 2023-02-05 - output.concat "#{s.name}" - end - else - output.concat s.name - end - output.concat @script_postfix - output.concat " (paused)" if s.paused? - - if @display_arguments && !(s.vars.empty?) - output.concat @script_argument_separator - output.concat @argument_prefix - output.concat s.vars.drop(1).join("#{@argument_postfix}#{@argument_separator}#{@argument_prefix}") - output.concat @argument_postfix - end - - output + output = "" + output.concat @script_prefix + if @enable_links + case $frontend + when 'genie' + # use alternate link syntax for genie, so end users don't need to enable it globally + # enabling links generally in genie can cause issus with .NET UI. This link syntax + # bypasses the global setting, which *shouldn't* cause the kind of problems enabling + # links globally in genie can cause + # genie alternate link syntax: {:} + output.concat "{#{s.name}:#{$clean_lich_char}#{s.paused? ? 'unpause' : 'pause'} #{s.name}}" + else + # standard link syntax for Wrayth (and maybe others?) + # in theory frostbite should use this, but there is a bug with multiple links in one + # line with current version at this time - (DD: 2023-08-22) + # v1.16.0-beta was released 2023-02-05 + output.concat "#{s.name}" + end + else + output.concat s.name + end + output.concat @script_postfix + output.concat " (paused)" if s.paused? + + if @display_arguments && !(s.vars.empty?) + output.concat @script_argument_separator + output.concat @argument_prefix + output.concat s.vars.drop(1).join("#{@argument_postfix}#{@argument_separator}#{@argument_prefix}") + output.concat @argument_postfix + end + + output } .join(@script_separator)