Module:NameGenerator: Difference between revisions

738 bytes removed ,  21:23, 30 May 2022
no edit summary
(name gen that isn't crab specific, i hope?)
 
No edit summary
Line 3: Line 3:


function p.main(frame)
function p.main(frame)
local naming = require'Module:Sandbox/User:Illuminatiswag/namegen/NamingTable'
local prefixes = ""
local prefixes = ""
local infixes = ""
local infixes = ""
Line 21: Line 22:
end
end


 
prefixtable = naming[style]['Prefixes']
--[get cargo row]--
infixtable = naming[style]['Infixes']
local tables= 'HeroNames'
postfixtable = naming[style]['Postfixes']
local fields= 'Prefixes, MinPrefixAmount, MaxPrefixAmount,Infixes, MinInfixAmount,MaxInfixAmount,Postfixes ,MinPostfixAmount,MaxPostfixAmount,TitleTemplate'
local args= {
where= 'BaseType="' .. style .. '"'
}
result = cargo.query(tables,fields,args)
if not next(result) then
error('no base type of that kind found.')
end
--[get prefixes array]--
local resultstring = ''
resultstring = result[1]['Prefixes']
local prefixtable= {}
local i = 1
for j in string.gmatch(resultstring,"%s*(%w+),?%s*") do
prefixtable[i] = j
i= i+1
end
--[get infixes array]--
local resultstring = ''
resultstring = result[1]['Infixes']
local infixtable= {}
local i = 1
for j in string.gmatch(resultstring,"%s*(%w+),?%s*") do
infixtable[i] = j
i= i+1
end
--[get postfixes array]--
local resultstring = ''
resultstring = result[1]['Postfixes']
local postfixtable= {}
local i = 1
for j in string.gmatch(resultstring,"%s*(%w+),?%s*") do
postfixtable[i] = j
i= i+1
end


--[get min/maxprefix stuff]--
--[get min/maxprefix stuff]--
minprefix=result[1]['MinPrefixAmount']
minprefix=naming[style]['MinPrefixAmount']
maxprefix=result[1]['MaxPrefixAmount']
maxprefix=naming[style]['MaxPrefixAmount']
for i=1,math.random(minprefix,maxprefix) do
for i=1,math.random(minprefix,maxprefix) do
   prefixes = prefixes.. prefixtable[math.random(table.getn(prefixtable))]
   prefixes = prefixes.. prefixtable[math.random(table.getn(prefixtable))]
end
end


mininfix=result[1]['MinInfixAmount']
mininfix=naming[style]['MinInfixAmount']
maxinfix=result[1]['MaxInfixAmount']
maxinfix=naming[style]['MaxInfixAmount']
for i=1,math.random(mininfix,maxinfix) do
for i=1,math.random(mininfix,maxinfix) do
   infixes = infixes.. infixtable[math.random(table.getn(infixtable))]
   infixes = infixes.. infixtable[math.random(table.getn(infixtable))]
end
end
minpostfix=result[1]['MinPostfixAmount']
minpostfix=naming[style]['MinPostfixAmount']
maxpostfix=result[1]['MaxPostfixAmount']
maxpostfix=naming[style]['MaxPostfixAmount']
for i=1,math.random(minpostfix,maxpostfix) do
for i=1,math.random(minpostfix,maxpostfix) do
   postfixes = postfixes.. postfixtable[math.random(table.getn(postfixtable))]
   postfixes = postfixes.. postfixtable[math.random(table.getn(postfixtable))]
Line 79: Line 45:


--[title template]--
--[title template]--
titletemplate=result[1]['TitleTemplate']
-- titletemplate=result[1]['TitleTemplate']


--[name fitting]--
--[name fitting]--
local heroname= ((prefixes..infixes..postfixes):gsub("^%l", string.upper))
local heroname= ((prefixes..infixes..postfixes):gsub("^%l", string.upper))
local a = string.gsub(titletemplate,'NAME',tostring(heroname))
-- local a = string.gsub(titletemplate,'NAME',tostring(heroname))
local b = string.gsub(a,('BASETYPE'), style)
-- local b = string.gsub(a,('BASETYPE'), style)
local b = heroname


return b
return b