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

Fixing text emit errors #16

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions plugins/txt/plugin/commands/txt_send_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TxtSendCmd

def parse_args
if (!cmd.args)
#why is this here?
self.names = []

elsif (cmd.args.start_with?("="))
Expand All @@ -22,31 +23,34 @@ 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
end
end

def check_approved
return nil if enactor.is_approved?
return nil if enactor.is_approved?
return t('dispatcher.not_allowed')
end

Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion plugins/txt/plugin/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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

Expand Down
14 changes: 11 additions & 3 deletions plugins/txt/plugin/web/add_txt_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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


Expand All @@ -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,
Expand Down