From 3b5fe229fbc83b7aa38b33c0b1e2dbd8bfdd0094 Mon Sep 17 00:00:00 2001 From: spiritlake <32268357+spiritlake@users.noreply.github.com> Date: Mon, 23 Nov 2020 21:15:32 -0500 Subject: [PATCH] Fixing text emit errors --- plugins/txt/plugin/commands/txt_send_cmd.rb | 10 +++++++--- plugins/txt/plugin/helpers.rb | 3 ++- plugins/txt/plugin/web/add_txt_handler.rb | 14 +++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/plugins/txt/plugin/commands/txt_send_cmd.rb b/plugins/txt/plugin/commands/txt_send_cmd.rb index a29a3417..b12b8e45 100644 --- a/plugins/txt/plugin/commands/txt_send_cmd.rb +++ b/plugins/txt/plugin/commands/txt_send_cmd.rb @@ -8,6 +8,7 @@ class TxtSendCmd def parse_args if (!cmd.args) + #why is this here? self.names = [] elsif (cmd.args.start_with?("=")) @@ -22,23 +23,26 @@ def parse_args if (args.arg1 && (args.arg1.include?("http://") || args.arg1.include?("https://")) ) self.names = enactor.txt_last self.message = "#{args.arg1}=#{args.arg2}" - + #Text a specific scene elsif ( args.arg1.include?("/") ) if args.arg1.rest("/").is_integer? self.scene_id = args.arg1.rest("/") self.names = list_arg(args.arg1.first("/")) self.message = trim_arg(args.arg2) + #Text the scene you are physically in elsif args.arg1.rest("/").chr.casecmp?("s") self.scene_id = enactor.room.scene_id self.names = list_arg(args.arg1.first("/")) self.message = trim_arg(args.arg2) end else + #Text someone without a scene self.names = list_arg(args.arg1) self.message = trim_arg(args.arg2) end else + #Text your last recipient and scene self.names = enactor.txt_last self.scene_id = enactor.txt_scene self.message = cmd.args @@ -46,7 +50,7 @@ def parse_args end def check_approved - return nil if enactor.is_approved? + return nil if enactor.is_approved? return t('dispatcher.not_allowed') end @@ -116,7 +120,7 @@ def handle end end - recipient_display_names = Txt.format_recipient_display_names(recipients) + recipient_display_names = Txt.format_recipient_display_names(recipients, enactor) recipient_names = Txt.format_recipient_names(recipients) sender_display_name = Txt.format_sender_display_name(enactor) diff --git a/plugins/txt/plugin/helpers.rb b/plugins/txt/plugin/helpers.rb index 9d93b7cd..34ff87b8 100644 --- a/plugins/txt/plugin/helpers.rb +++ b/plugins/txt/plugin/helpers.rb @@ -6,7 +6,7 @@ def self.format_txt_indicator(char, names) :start_marker => Global.read_config("txt", "txt_start_marker") || "(", :end_marker => Global.read_config("txt", "txt_end_marker") || ")", :preface => Global.read_config("txt", "txt_preface"), :recipients => names, :color => Txt.txt_color(char) ) end - def self.format_recipient_display_names(recipients) + def self.format_recipient_display_names(recipients, sender) use_nick = Global.read_config("txt", "use_nick") use_only_nick = Global.read_config("txt", "use_only_nick") recipient_display_names = [] @@ -25,6 +25,7 @@ def self.format_recipient_display_names(recipients) recipient_display_names.concat [char.name] end end + recipient_display_names.delete(sender.name) return t('txt.recipient_indicator', :recipients => recipient_display_names.join(" ")) end diff --git a/plugins/txt/plugin/web/add_txt_handler.rb b/plugins/txt/plugin/web/add_txt_handler.rb index dd8fd88d..49059af8 100644 --- a/plugins/txt/plugin/web/add_txt_handler.rb +++ b/plugins/txt/plugin/web/add_txt_handler.rb @@ -54,13 +54,12 @@ def handle(request) message = pose.rest("=") end else - recipients = scene.participants + recipients = scene.participants.to_a message = pose end - recipients_minus = recipients.delete(enactor) recipient_names = Txt.format_recipient_names(recipients) - recipient_display_names = Txt.format_recipient_display_names(recipients) + recipient_display_names = Txt.format_recipient_display_names(recipients, enactor) sender_display_name = Txt.format_sender_display_name(enactor) scene_room = scene.room use_only_nick = Global.read_config("txt", "use_only_nick") @@ -90,6 +89,13 @@ def handle(request) end end + txt_received = "#{recipient_names}" + txt_received.slice! "#{char.name}" + puts char.txt_received + char.update(txt_received: (txt_received.squish)) + char.update(txt_received_scene: scene_id) + puts char.txt_received + #Emit to online players @@ -111,6 +117,8 @@ def handle(request) end end + + scene_txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name,