Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ @mail assistance
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Fri 28 Nov 2008 06:36 AM (UTC) |
Message
| I have an alias for sending @mails easier, but would like to extend it some so it auto %r's it when a line reaches 65+ chars, but at the word boundary that crosses it, so the word that makes the line go over 65 chars would have a %r placed prior to it.
I am out of coding practice, and the whole use it or lose it applies to my brain and coding.
Alias Follows:
<aliases>
<alias
name="Compose_Mail"
match="^ComposeMail$"
enabled="y"
omit_from_command_history="y"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>persons = utils.inputbox ( "Enter Person(s)'s Name", "Enter Addresse:")
if persons == nil then return end -- if
message = utils.editbox ( "Enter @Mail Message", "Enter Message:")
if message == nil then return end -- if
message_parse = Replace(message,"\\\\r\\\\n","/",false)
message_parse = Replace(message_parse,"\\\\r\\\\n","%%r",true)
message_parse = Replace(message_parse,"\\\\t","%%t",true)
SetCommand("@mail ".. persons.."="..message_parse)</send>
</alias>
</aliases>
-Onoitsu2 | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 28 Nov 2008 08:37 PM (UTC) |
Message
| Without writing the whole thing, I would imagine something like this might work:
for w in string.gmatch (message_parse, "%S+") do
-- if (length of current line) + #w > 65 then
-- append %r
-- end -- if
-- append w to current line
end -- for
That is breaking your message up into batches of things that are not spaces (%S) and building them into lines.
However it is a bit fiddlier than that, because if there is already a %r in that batch, you have to reset the line length.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Reply #2 on Tue 02 Dec 2008 11:35 AM (UTC) Amended on Tue 02 Dec 2008 11:37 AM (UTC) by Onoitsu2
|
Message
| I think I have created something that will sufficiently wrap my inputted message to about 65 characters, it will also wrap shorter if it runs into an sentence or question ending punctuation mark. Still buggy a little, but works well for what I needed it for.
-Onoitsu2
<aliases>
<alias
name="Compose_Mail"
match="^ComposeMail$"
enabled="y"
omit_from_command_history="y"
regexp="y"
send_to="12"
ignore_case="y"
sequence="100"
>
<send>persons = utils.inputbox ( "Enter Person(s)'s Name", "Enter Addresse:")
if persons == nil then return end -- if
message = utils.editbox ( "Enter @Mail Message", "Enter Message:")
if message == nil then return end -- if
message = Replace(message,"\\r\\n","/",false)
message_start = string.find(message,"/",1,true)
title = string.sub(message,1,message_start-1)
message = string.sub(message,message_start+1)
message = Replace(message,"\\r\\n","%%r ",true)
message = Replace(message,"\\t","%%t ",true)
--print(title)
--print(message)
message_table = {}
line_length = 0
for word in string.gmatch (message, "%S+") do
line_length = line_length + #word + 1 -- add in possible space
--print(word .. " " .. #word)
--print(line_length)
if string.match(word,"%%r ") then
line_length = 0
table.insert(message_table,word)
else
if string.match(word,"[%.%!%?]") and line_length >= 65 then
line_length = 0
table.insert(message_table,word.."%r ")
else
if line_length >= 75 then
line_length = 0
table.insert(message_table,word.."%r ")
else
table.insert(message_table,word)
end -- if
end -- if
end -- if
end -- for
--print("----")
for k, v in ipairs (message_table) do
--print(v .. " " .. #v)
--print(#message)
if k > 1 then
if string.match(v,"%%r ") then
message = message .. v
else
if k == #message_table then
message = message .. v
else
message = message .. v .. " "
end -- if
end -- if
else
message = v .. " "
end -- if
end -- for
message = Replace(message,"%r ","%r",true)
message = Replace(message,"%t ","%t",true)
--print(message)
SetCommand("@mail ".. persons.."="..title.."/"..message)</send>
</alias>
</aliases>
| Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,776 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top