Skip to content

Commit

Permalink
Merge pull request #15 from spiritlake/master
Browse files Browse the repository at this point in the history
Text updates
  • Loading branch information
lynnfaraday authored Nov 23, 2020
2 parents 256be63 + 4905277 commit 6c5bfde
Show file tree
Hide file tree
Showing 22 changed files with 1,005 additions and 184 deletions.
11 changes: 11 additions & 0 deletions plugins/txt/game/config/txt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
txt:
use_nick: false
use_only_nick: false
txt_start_marker: (
txt_end_marker: )
txt_preface: "TXT"
scene_type: "Text"
location: "Text"
shortcuts:
text: txt
21 changes: 15 additions & 6 deletions plugins/txt/plugin/commands/txt_new_scene.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ def parse_args
self.names = []
else
args = cmd.parse_args(ArgParser.arg1_equals_arg2)
self.names = list_arg(args.arg1)
self.names_raw = trim_arg(args.arg1)
self.message = trim_arg(args.arg2)
if (args.arg1 && (args.arg1.include?("http://") || args.arg1.include?("https://")) )
self.names = []
else
self.names = list_arg(args.arg1)
self.names_raw = trim_arg(args.arg1)
self.message = trim_arg(args.arg2)
end
end
end

def required_args
[ self.names, self.message ]
def check_approved
return nil if enactor.is_approved?
return t('dispatcher.not_allowed')
end

def check_txt_target
Expand All @@ -35,7 +40,11 @@ def handle
end
end

scene = Scenes.start_scene(enactor, "Text", true, "Text", true)
scene_type = Global.read_config("txt", "scene_type")
location = Global.read_config("txt", "location")
scene = Scenes.start_scene(enactor, location, true, false, scene_type, true)

# Scenes.create_scene_temproom(scene)

Global.logger.info "Scene #{scene.id} started by #{enactor.name} in Temp Txt Room."

Expand Down
67 changes: 38 additions & 29 deletions plugins/txt/plugin/commands/txt_send_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TxtSendCmd
include CommandHandler
# Possible commands... txt name=message; txt =message; txt name[/optional scene #]=<message>

attr_accessor :names, :message, :scene_id, :scene, :txt, :txt_recipient
attr_accessor :names, :message, :scene_id, :scene, :txt, :txt_recipient, :use_only_nick

def parse_args
if (!cmd.args)
Expand Down Expand Up @@ -45,6 +45,11 @@ def parse_args
end
end

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

def check_txt_target
return t('txt.txt_target_missing') if !self.names || self.names.empty?
return nil
Expand All @@ -55,7 +60,7 @@ def handle
# Is scene real and can you text to it?
if self.scene_id
scene = Scene[self.scene_id]
can_txt_scene = Scenes.can_edit_scene?(enactor, scene)
can_txt_scene = Scenes.can_join_scene?(enactor, scene)
if !scene
client.emit_failure t('txt.scene_not_found')
return
Expand All @@ -71,24 +76,23 @@ def handle
self.scene = scene
end

#Are recipients real and online?
#Are recipients real, online, and in the scene?
recipients = []
self.names.each do |name|
char = Character.named(name)

if !char
client.emit_failure t('txt.no_such_character')
return
elsif (!Login.is_online?(char) && !self.scene)
client.emit_failure t('txt.target_offline_no_scene', :name => name )
client.emit_failure t('txt.target_offline_no_scene', :name => name.titlecase )
return
else
recipients.concat [char]
end

#Add recipient to scene
#Add recipient to scene if they are not already a participant
if self.scene
can_txt_scene = Scenes.can_edit_scene?(char, self.scene)
can_txt_scene = Scenes.can_join_scene?(char, self.scene)
if (!can_txt_scene)
Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', :name => char.name ),
enactor, nil, true )
Expand All @@ -112,31 +116,38 @@ def handle
end
end

recipient_names = Txt.format_recipient_indicator(recipients)
recipient_display_names = Txt.format_recipient_display_names(recipients)
recipient_names = Txt.format_recipient_names(recipients)
sender_display_name = Txt.format_sender_display_name(enactor)

self.use_only_nick = Global.read_config("txt", "use_only_nick")
# If scene, add text to scene
if self.scene
scene_txt = t('txt.txt_to_scene_with_recipient',
:txt => Txt.format_txt_indicator(enactor, recipient_names),
:sender => enactor.name,
# :recipients => recipient_names,
:message => message,
:scene_id => self.scene_id )
if self.use_only_nick
scene_id = "#{self.scene_id} - #{enactor.name}"
else
scene_id = self.scene_id
end

scene_txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message)

self.txt = t('txt.txt_with_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :scene_id => scene_id )

Scenes.add_to_scene(self.scene, scene_txt, enactor)
Rooms.emit_ooc_to_room self.scene.room, scene_txt
end
else
if self.use_only_nick
self.txt = t('txt.txt_no_scene_id_nick', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :sender_char => enactor.name )
else
self.txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message)
end

# If online, send emit to sender and recipients.
end

self.txt = t('txt.txt_to_sender',
:txt => Txt.format_txt_indicator(enactor, recipient_names),
:sender => enactor.name,
# :recipients => recipient_names,
:message => message)
# If online, send emit to sender and recipients if they aren't in the scene's room.
#To recipients
recipients.each do |char|
if Login.is_online?(char)
if (Login.is_online?(char)) && (!self.scene || char.room != self.scene.room)
recipient = char

if recipient.page_ignored.include?(enactor)
Expand All @@ -146,24 +157,22 @@ def handle
client.emit_ooc t('page.recipient_do_not_disturb', :name => recipient.name)
return
end
Txt.txt_recipient(enactor, recipient, recipient_names, self.txt, self.scene_id)
Txt.txt_recipient(enactor, recipient, recipient_display_names, self.txt, scene_id)
end
end

#To sender
if self.scene_id && (enactor.room.scene_id != self.scene_id)
client.emit "#{self.txt} %xh%xx(Scene #{self.scene_id})"
else
if (!self.scene || enactor_room != self.scene.room)
client.emit self.txt
end

enactor.update(txt_last: list_arg(recipient_names))
enactor.update(txt_scene: self.scene_id)

end

def log_command
# Don't log texts
# Don't log texts
end

end
end
end
21 changes: 12 additions & 9 deletions plugins/txt/plugin/help/en/txt.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
---
toc: Playing the Game
toc: 4 - Writing the Story
summary: How to send texts.
aliases:
- text
- Texting
- texts
---
#Texts
Send text messages to other characters.

> Learn how the text system works in the [Text Tutorial](/help/txt_tutorial).
## Texting from the Web-Portal
There is a "Send Txt" button on any active scene in the web-portal. Texting into a scene will send a message in-game, if the character is connected. Otherwise, it will just send a text into the scene.
There is a "Txt" button on any active scene in the web-portal. Texting into a scene will send a message in-game, if the character is connected. By default, texting on the portal will send a text to all participants of the scene.

`<name>=<message>` - Send a message to a person from the webportal. If the recipient isn't already a participant in the scene, this will add them.
`<name>=<message>` - Send a message to a specific person from the webportal. Adds recipients to scene if not already a participant.

> Keep in mind that someone who's not logged in won't know they've been texted in a scene unless they check! Be courteous!
> **Note:** Someone who's not logged in may not know they've been texted unless they notice their notifications!
## Commands
`txt <name> [<name> <name>]=<message>` - Send a message to name(s).
`txt <name> [<name> <name>]/<scene #>=<message>` - Send a text to name + log it in a scene. If the recipient isn't already a participant in the scene, this will add them.
`txt/newscene <name> [<name> <name>]=<message>` - Starts a new scene + sends a message to those names + the scene.

`txt <name> [<name> <name>]=<message>` - Send a message to name(s) outside of a scene.
`txt <name> [<name> <name>]/<scene #>=<message>` - Send a text to name + add it to a scene. Adds recipients to scene if not already a participant.
`txt [=]<message>` - Send a message to your last text target + last scene.

`txt/reply` - See who last texted you.
`txt/reply <message>` - Reply to the last text (including all recipients + scene, if there is one)

`txt/newscene <name> [<name> <name>]=<message>` - Starts a new scene + sends a message to those names + the scene.

`txt/color <color>` - Color the (TXT to <name>) prefix. Use ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%xg for green highlight.

> If you do not wish to receive txts (in general, or from a specific person), the `page/ignore <name>=<on/off>` and `page/dnd <on/off>` commands will block txts as well.
> **Note:** If you do not wish to receive txts (in general, or from a specific person), the `page/ignore <name>=<on/off>` and `page/dnd <on/off>` commands will block txts as well.
60 changes: 60 additions & 0 deletions plugins/txt/plugin/help/en/txt_tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
toc: 4 - Writing the Story
tutorial: true
summary: How to send texts.
---
# Texts

The text plugin lets you send text messages to other characters.

[[toc]]

##Sending Texts without a Scene

On the game, you can text characters online by sending a text without specifying a scene number. These texts are not added to any scene and will not be logged or saved unless you do so manually.

Do `txt <name>=<message>` to send a text without adding it to a scene.

> **Note:** Texting characters without an attached scene only works when all characters are logged in to the game via telnet; it will not work via the portal. Texting via the portal requires a scene.
##Sending Texts in a Scene

###Starting a Scene

On game, you can start a new text scene in one easy step.

`txt/newscene <name> [<name}]=<message>`

This will start a new scene, set the location and scene type, emit the text to all characters currently online, and add the text to the scene.

On the portal, you will need to [start a scene](/help/scenes_tutorial#starting-a-scene) and set the location and type manually.

###Replying to Texts

####On Game
If someone sends you a text, you can quickly reply to the text using `txt/reply=<message>`. This will send your text to everyone in the recipient list and add it to the scene. To see who last texted you, type `txt/reply`

On the game, the 'txt' command will remember the last character and scene you texted. If you continue to text the same person, you can simply do `txt <name> [<name}]=<message>`.

If you're texting several different recipients or to several different scenes at once, you'll need to specify who you are texting and what scene it should be added to by doing `txt <name> [<name}]/<scene>=<message>`.

If you text someone who was not previously in that scene, they will automatically be added to the scene.

####On the Portal
Texts sent from the portal add the texts to the scene and emit to anyone who is online on the game.

Send texts by using the 'Txt' button next to the 'Add OOC' and 'Add Pose' buttons on the portal. By default, this button texts everyone in the scene.

To send texts to a different recipient list, do `<name> [name]=<message>` and use the 'Txt' button.

##Text Settings

###Text Color

You can choose a personal text color to make text scenes more readable. Do `txt/color <color>` to set your personal color. You can view available colors by doing `colors`, `colors1`, `colors2`, etc.

Use the full ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%x46 for bright green highlight, etc.

###Ignoring or Blocking Texts

If you do not wish to receive txts (in general, or from a specific person), the `page/ignore <name>=<on/off>` and `page/dnd <on/off>` commands will block txts as well.
68 changes: 50 additions & 18 deletions plugins/txt/plugin/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,70 @@ module Txt

def self.format_txt_indicator(char, names)
t('txt.txt_indicator',
# :start_marker => Global.read_config("page", "page_start_marker") || "<",
# :end_marker => Global.read_config("page", "page_end_marker") || "<",
:start_marker => "(",
:recipients => names,
:end_marker => ")",
:color => Txt.txt_color(char) )
: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_indicator(recipients)
recipient_names = []
def self.format_recipient_display_names(recipients)
use_nick = Global.read_config("txt", "use_nick")
use_only_nick = Global.read_config("txt", "use_only_nick")
recipient_display_names = []
recipients.each do |char|
recipient_names.concat [char.name]
if use_nick
puts "USE ONLY NICK"
recipient_display_names.concat [char.nick]
elsif use_only_nick
nickname_field = Global.read_config("demographics", "nickname_field") || ""
if (char.demographic(nickname_field))
recipient_display_names.concat [char.demographic(nickname_field)]
else
recipient_display_names.concat [char.name]
end
else
recipient_display_names.concat [char.name]
end
end
return t('txt.recipient_indicator', :recipients => recipient_display_names.join(" "))
end

def self.format_sender_display_name(sender)
use_nick = Global.read_config("txt", "use_nick")
use_only_nick = Global.read_config("txt", "use_only_nick")
if use_nick
sender_display_name = sender.nick
elsif use_only_nick
nickname_field = Global.read_config("demographics", "nickname_field") || ""
if (sender.demographic(nickname_field))
sender_display_name = sender.demographic(nickname_field)
else
sender_display_name = sender.name
end
else
sender_display_name = sender.name
end
return sender_display_name
end

def self.format_recipient_names(recipients)
recipient_names = []
recipients.each do |char|
if !char
return { error: t('txt.no_such_character') }
else
recipient_names.concat [char.name]
end
end
return t('txt.recipient_indicator', :recipients => recipient_names.join(" "))
end

def self.txt_color(char)
char.txt_color || "%xh%xy"
end

def self.txt_recipient(sender, recipient, recipient_names, message, scene_id)
def self.txt_recipient(sender, recipient, recipient_names, message, scene_id = nil)
client = Login.find_client(sender)
recipient_client = Login.find_client(recipient)
if scene_id
Login.emit_if_logged_in recipient, "#{message} %xh%xx(Scene #{scene_id})"
Page.send_afk_message(client, recipient_client, recipient)
else
Login.emit_if_logged_in recipient, message
Page.send_afk_message(client, recipient_client, recipient)
end

Login.emit_if_logged_in recipient, message
Page.send_afk_message(client, recipient_client, recipient)
txt_received = "#{recipient_names}" + " #{sender.name}"
txt_received.slice! "#{recipient.name}"
recipient.update(txt_received: (txt_received.squish))
Expand Down
Loading

0 comments on commit 6c5bfde

Please sign in to comment.