Advertisement
fuxoft

FFChat Nickname generator

May 12th, 2013
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local function new_session(id)
  2.     local souhlaska = function()
  3.         local all = {"b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","č","ř","š","ž"}
  4.         return all[math.random(#all)]
  5.     end
  6.     local samohlaska = function()
  7.         local all = {"a","e","i","o","u","y","a","e","i","o","u","y","a","e","i","o","u","y","á","é","í","ó","ů","ý"}
  8.         return all[math.random(#all)]
  9.     end
  10.     assert(id)
  11.     local res = {id = id, chat_lines = persistent.recent_lines(), connections={}}
  12.     local ltrs = {}
  13.     if math.random()>0.5 then
  14.         table.insert(ltrs,souhlaska())
  15.     end
  16.     if math.random()>0.8 then
  17.         table.insert(ltrs,samohlaska())
  18.         table.insert(ltrs,souhlaska())
  19.         if math.random()<0.2 then
  20.             table.insert(ltrs,souhlaska())
  21.         end
  22.     end
  23.     table.insert(ltrs,samohlaska())
  24.     table.insert(ltrs,souhlaska())
  25.     if math.random()<0.2 then
  26.         table.insert(ltrs,souhlaska())
  27.     end
  28.     table.insert(ltrs,samohlaska())
  29.     table.insert(ltrs, "nym")
  30.     ltrs[1] = ({["č"] = "Č", ["ř"] = "Ř", ["š"] = "Š", ["ž"] = "Ž", ["á"] = "Á", ["é"] = "É", ["í"] = "Í", ["ó"] = "Ó", ["ů"] = "Ú", ["ý"] = "Ý"})[ltrs[1]] or ltrs[1]:upper()
  31.     res.name = table.concat(ltrs)
  32.     private_message(res,"Teď jsi anonym jménem <b>"..res.name.."</b>. Chatuj nebo napiš otazník...")
  33.     return res
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement