FANDOM


-- Random Functions Library
 
 
local RFL = {}
-- Setup
math.randomseed(os.time())
 
-- Constants
local pronouns = {
    nominative = {'he', 'she', 'it'},
    genitive =   {'his', 'hers', 'its'},
    accusative = {'him', 'her', 'it'}
}
 
local ErrorMessages = {
    IMPROPER_GRAMMATICAL_CASE = "<span style='color: red;'>Improper grammatical case</span>"
}
 
function RFL.RandomIntegerFromRangeExclusiveEnd(lowerBound, upperBound)
    ---
     -- Returns psudo-random number from range [lowerBound, upperBound[
    ---
     return math.floor(math.random() * (upperBound - lowerBound) + lowerBound)
end
 
function RFL.RandomPronoun(frame)
    ---
     -- Chooses random personal pronoun in appropriate form for each 
     --   function call
    ---
    local grammaticalCase = frame.args[1]
    if(pronouns[grammaticalCase] == nil) then
        return ErrorMessages.IMPROPER_GRAMMATICAL_CASE
    else
        local pronounIndex = RFL.RandomIntegerFromRangeExclusiveEnd(0, table.getn(pronouns[grammaticalCase])) + 1
        return pronouns[grammaticalCase][pronounIndex]
    end
end
 
return RFL;

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.