rot13 script

Share your scripts and packages with other Mudlet users.
Post Reply
Oreolek
Posts: 2
Joined: Mon Mar 19, 2018 1:12 pm

rot13 script

Post by Oreolek » Mon Mar 19, 2018 1:32 pm

A rot13 ASCII alias command (actually, it's rot-anything):

Code: Select all

<regex>^rot(\d+) (.*)</regex>
<script>
local KEY = matches[2]
local line = matches[3]

function Rotate(t)
  return (string.gsub(t, "[%a]",
    function (char)
      local bUpper = (char < 'a')
      local b = string.byte(string.upper(char)) - 65 -- 0 to 25
      b = math.mod(b + KEY, 26)
      if bUpper then
        return string.char(b + 65)
      else
        return string.char(b + 97)
      end
    end
  ))
end

echo(Rotate(line).."\n")
</script>

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest