Changed: Use # in Lua to get the size of an array

--HG--
branch : develop
feature/pipeline-tools
kervala 9 years ago
parent d113bb7b10
commit 5121cdb7d4

@ -20,15 +20,13 @@ end
-- Fyros -- Fyros
function outgame:getFyrosFirstName() function outgame:getFyrosFirstName()
local nbFyrosFirstNames = 0 local nbFyrosFirstNames = #fyrosFirstNames
for _ in pairs(fyrosFirstNames) do nbFyrosFirstNames = nbFyrosFirstNames + 1 end
return fyrosFirstNames[math.random(nbFyrosFirstNames)] return fyrosFirstNames[math.random(nbFyrosFirstNames)]
end end
function outgame:getFyrosLastName() function outgame:getFyrosLastName()
local nbFyrosLastNames = 0 local nbFyrosLastNames = #fyrosLastNames
for _ in pairs(fyrosLastNames) do nbFyrosLastNames = nbFyrosLastNames + 1 end
return fyrosLastNames[math.random(nbFyrosLastNames)] return fyrosLastNames[math.random(nbFyrosLastNames)]
end end
@ -44,12 +42,10 @@ function outgame:getMatisFirstName(sex)
local FirstName = "" local FirstName = ""
if tonumber(dbNameSex) == 1 then if tonumber(dbNameSex) == 1 then
local nbMatisMaleFirstNames = 0 local nbMatisMaleFirstNames = #matisMaleFirstNames
for _ in pairs(matisMaleFirstNames) do nbMatisMaleFirstNames = nbMatisMaleFirstNames + 1 end
FirstName = matisMaleFirstNames[math.random(nbMatisMaleFirstNames)] FirstName = matisMaleFirstNames[math.random(nbMatisMaleFirstNames)]
else else
local nbMatisFemaleFirstNames = 0 local nbMatisFemaleFirstNames = #matisFemaleFirstNames
for _ in pairs(matisFemaleFirstNames) do nbMatisFemaleFirstNames = nbMatisFemaleFirstNames + 1 end
FirstName = matisFemaleFirstNames[math.random(nbMatisFemaleFirstNames)] FirstName = matisFemaleFirstNames[math.random(nbMatisFemaleFirstNames)]
end end
@ -57,44 +53,37 @@ function outgame:getMatisFirstName(sex)
end end
function outgame:getMatisLastName() function outgame:getMatisLastName()
local nbMatisLastNames = #matisLastNames
local nbMatisLastNames = 0
for _ in pairs(matisLastNames) do nbMatisLastNames = nbMatisLastNames + 1 end
return matisLastNames[math.random(nbMatisLastNames)] return matisLastNames[math.random(nbMatisLastNames)]
end end
-- Tryker -- Tryker
function outgame:getTrykerFirstName() function outgame:getTrykerFirstName()
local nbTrykerFirstNames = 0 local nbTrykerFirstNames = #trykerFirstNames
for _ in pairs(trykerFirstNames) do nbTrykerFirstNames = nbTrykerFirstNames + 1 end
return trykerFirstNames[math.random(nbTrykerFirstNames)] return trykerFirstNames[math.random(nbTrykerFirstNames)]
end end
function outgame:getTrykerLastName() function outgame:getTrykerLastName()
local nbTrykerLastNames = 0 local nbTrykerLastNames = #trykerLastNames
for _ in pairs(trykerLastNames) do nbTrykerLastNames = nbTrykerLastNames + 1 end
return trykerLastNames[math.random(nbTrykerLastNames)] return trykerLastNames[math.random(nbTrykerLastNames)]
end end
-- Zoraï -- Zoraï
function outgame:getZoraiFirstName() function outgame:getZoraiFirstName()
local nbFirstNamesOne = 0 local nbFirstNamesOne = #zoraiFirstNamesOne
for _ in pairs(zoraiFirstNamesOne) do nbFirstNamesOne = nbFirstNamesOne + 1 end
local FirstNameOne = zoraiFirstNamesOne[math.random(nbFirstNamesOne)] local FirstNameOne = zoraiFirstNamesOne[math.random(nbFirstNamesOne)]
local nbFirstNamesTwo = 0 local nbFirstNamesTwo = #zoraiFirstNamesTwo
for _ in pairs(zoraiFirstNamesTwo) do nbFirstNamesTwo = nbFirstNamesTwo + 1 end
local FirstNameTwo = zoraiFirstNamesTwo[math.random(nbFirstNamesTwo)] local FirstNameTwo = zoraiFirstNamesTwo[math.random(nbFirstNamesTwo)]
return FirstNameOne .. "-" .. FirstNameTwo return FirstNameOne .. "-" .. FirstNameTwo
end end
function outgame:getZoraiLastName() function outgame:getZoraiLastName()
local nbLastNames = 0 local nbLastNames = #zoraiLastNames
for _ in pairs(zoraiLastNames) do nbLastNames = nbLastNames + 1 end
return zoraiLastNames[math.random(nbLastNames)] return zoraiLastNames[math.random(nbLastNames)]
end end

Loading…
Cancel
Save