Guest User

Untitled

a guest
May 20th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. local function ReplaceDigit(digit)
  2.     DigitToNumeral = {[""] = "\"",["1"] = "\"",["2"] = "II\"",["3"] = "III\"",["4"] = "IV\"",["5"] = "V\"",["6"] = "VI\"",["7"] = "VII\""}
  3.     local result = DigitToNumeral[digit]
  4.     if result ~= nil then
  5.         return result
  6.     else
  7.         return digit
  8.     end
  9. end
  10.  
  11. function handle_Game_command(typed,command)
  12.     ScriptWrapper:Print(command,0)
  13.     if typed then -- typed command
  14.         local Ismagic = nil
  15.         if command:find("/ma ") ~= nil then -- /ma somespell 3 <t>
  16.             Ismagic = "(/ma )(%w)"
  17.         elseif command:find("/magic ") ~= nil then -- /magic somespell 3 <t>
  18.             Ismagic = "(/magic )(%w)"
  19.         end
  20.        
  21.         if Ismagic ~= nil then -- takes /ma somespell 3 sometarget and returns /ma "Somespell III" sometarget
  22.             return string.gsub(string.gsub(command, Ismagic, function(a,b) return a.."\""..string.upper(b) end, 1), "(%d+)", ReplaceDigit, 1) -- /ma "somespell III" <t>
  23.         end
  24.     end
  25.     return false
  26. end
  27.  
  28. ScriptWrapper:RegisterHandler(1, "handle_Game_command")
Add Comment
Please, Sign In to add comment