Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length = 10
- local tDictionary = {}
- local shado = {}
- while true do
- sLine = read()
- local tWords = {}
- for match in string.gmatch(sLine, "[^ \t]+") do
- table.insert( tWords, match )
- end
- for i = 1,#tWords do
- if tDictionary[tWords[i]] then
- table.insert(tDictionary[tWords[i]]["to"],tWords[i])
- else
- table.insert(shado,tWords[i])
- tDictionary[tWords[i]] = {}
- tDictionary[tWords[i]]["name"] = tWords[i]
- tDictionary[tWords[i]]["to"] = {}
- end
- end
- local test = ""
- local last = nil
- for i = 1,math.random(1,length) do
- if last then
- if #tDictionary[last]["to"] and #tDictionary[last]["to"] > 0 then
- sNext = tDictionary[last]["to"][math.random(1,#tDictionary[last]["to"])]
- if sNext ~= last then
- test = test..sNext.." "
- last = sNext
- else
- last = tDictionary[shado[math.random(1,#shado)]]["name"]
- test = test..last.." "
- end
- else
- last = tDictionary[shado[math.random(1,#shado)]]["name"]
- test = test..last.." "
- end
- else
- last = tDictionary[shado[math.random(1,#shado)]]["name"]
- test = test..last.." "
- end
- end
- print(test)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement