Difference between revisions of "Module:String"
CommanderC (talk | contribs) (Created page with "local p = {} function p.first_word(frame) local text = frame.args[1] for token in string.gmatch(text, "[^%s]+") do return token end end return p") |
CommanderC (talk | contribs) |
||
| Line 6: | Line 6: | ||
return token | return token | ||
end | end | ||
| + | end | ||
| + | |||
| + | function p.fix_magic_resistance(frame) | ||
| + | local text = frame.args[1] | ||
| + | if text == "Immune" or text == "immune" then | ||
| + | return "1000" | ||
| + | end | ||
| + | return text | ||
end | end | ||
return p | return p | ||
Revision as of 15:17, 29 November 2013
Small functions for string manipulation.
local p = {}
function p.first_word(frame)
local text = frame.args[1]
for token in string.gmatch(text, "[^%s]+") do
return token
end
end
function p.fix_magic_resistance(frame)
local text = frame.args[1]
if text == "Immune" or text == "immune" then
return "1000"
end
return text
end
return p