Advertisement
bennyuoppd

talker

Aug 24th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. length = 10
  2. local tDictionary = {}
  3. local shado = {}
  4. while true do
  5. sLine = read()
  6. local tWords = {}
  7. for match in string.gmatch(sLine, "[^ \t]+") do
  8. table.insert( tWords, match )
  9. end
  10. for i = 1,#tWords do
  11. if tDictionary[tWords[i]] then
  12. table.insert(tDictionary[tWords[i]]["to"],tWords[i])
  13. else
  14. table.insert(shado,tWords[i])
  15. tDictionary[tWords[i]] = {}
  16. tDictionary[tWords[i]]["name"] = tWords[i]
  17. tDictionary[tWords[i]]["to"] = {}
  18. end
  19. end
  20. local test = ""
  21. local last = nil
  22. for i = 1,math.random(1,length) do
  23. if last then
  24. if #tDictionary[last]["to"] and #tDictionary[last]["to"] > 0 then
  25. sNext = tDictionary[last]["to"][math.random(1,#tDictionary[last]["to"])]
  26. if sNext ~= last then
  27. test = test..sNext.." "
  28. last = sNext
  29. else
  30. last = tDictionary[shado[math.random(1,#shado)]]["name"]
  31. test = test..last.." "
  32. end
  33. else
  34. last = tDictionary[shado[math.random(1,#shado)]]["name"]
  35. test = test..last.." "
  36. end
  37. else
  38. last = tDictionary[shado[math.random(1,#shado)]]["name"]
  39. test = test..last.." "
  40. end
  41. end
  42. print(test)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement