Module:String

From Infestation MMO Wiki
Jump to: navigation, search

local p = {}

function p.length( frame )

   local arg1 = frame.args[1]
   return string.len( arg1 )

end

function p.sub( frame )

   local arg1 = frame.args[1]
   local arg2 = tonumber( frame.args[2] )
   local arg3 = tonumber( frame.args[3] )
   if arg2 and arg3 then
       local first = arg2 + 1
       local last  = arg2 + arg3
       return string.sub( arg1, first, last )
   else
       return ""
   end

end

return p